#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  int k = t + 1;
  bool b = 0, f;
  while (1) {
    f = 0;
    if (b) {
      cout << k << endl;
      return 0;
    } else {
      vector<int> s;
      int c = k;
      while (c) {
        int p = c % 10;
        s.push_back(p);
        c /= 10;
      }
      sort(s.begin(), s.end());
      for (int z = 0; z < s.size() - 1; z++) {
        if (s[z] == s[z + 1]) {
          f = 1;
        }
      }
      if (f)
        k++;
      else
        b = 1;
    }
  }
}
