#include <iostream>
#include <unordered_set>
using namespace std;
bool ckeck(int n)
{
unordered_set<int> digits;
while (n > 0)
{
int digit = n % 10;
if (digits.count(digit) > 0) return 0;
digits.insert(digit);
n /= 10;
}
return 1;
}
int main()
{
int n;
cin >> n;
while (++ n)
if (ckeck(n))
{
cout << n;
return 0;
}
}