#include <bits/stdc++.h>
using namespace std;
bool isUnique(int n) {
  string k = to_string(n);
  set<char> s;
  for (char c : k) s.insert(c);
  return s.size() == 4;
}
int main() {
  int n;
  cin >> n;
  n++;
  while (!isUnique(n)) n++;
  cout << n << endl;
}
