#include <bits/stdc++.h>
using namespace std;
bool ktra(int n) {
  int vs[10] = {0};
  while (n != 0) {
    int a = n % 10;
    if (vs[a] == 1)
      return false;
    else
      vs[a] = 1;
    n /= 10;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  int res = 0;
  while (true) {
    if (ktra(n + 1)) {
      res = n + 1;
      break;
    }
    n += 1;
  }
  cout << res << endl;
  return 0;
}
