#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  int o, t, th, f;
  for (int i = x + 1;; i++) {
    o = i % 10;
    t = ((i % 100) - o) / 10;
    th = ((i % 1000) - ((t * 10) + o)) / 100;
    f = ((i % 10000) - ((t * 10) + o + (th * 100))) / 1000;
    if ((o != t && o != th && o != f) && (t != th && t != f) && (th != f)) {
      cout << (f * 1000) + (th * 100) + (t * 10) + (o) << endl;
      break;
    }
  }
  return 0;
}
