#include <bits/stdc++.h>
using namespace std;
void warm_up() {}
void solve() {
  int n;
  cin >> n;
  while (++n) {
    string ns = to_string(n);
    if (ns[0] == ns[1] || ns[0] == ns[2] || ns[0] == ns[3] || ns[1] == ns[2] ||
        ns[1] == ns[3] || ns[2] == ns[3]) {
      continue;
    } else {
      cout << n << "\n";
      return;
    }
  }
}
int32_t main() {
  warm_up();
  solve();
  return 0;
}
