#include <bits/stdc++.h>
using namespace std;
int kkaass = 1;
int main() {
  int a;
  cin >> a;
  int b = a + 1;
  while (b) {
    int x = b;
    bool f[10] = {0};
    bool bahir = true;
    while (x) {
      int g = x % 10;
      if (f[g]) {
        bahir = false;
        break;
      } else
        f[g] = true;
      x /= 10;
    }
    if (bahir) {
      cout << b << endl;
      return 0;
    }
    b++;
  }
  return 0;
}
