#include <bits/stdc++.h>
using namespace std;
int digits(int n) {
  int a, b, c, d;
  a = n % 10;
  b = (n / 10) % 10;
  c = (n / 100) % 10;
  d = (n / 1000) % 10;
  if (a != b && a != c && a != d && b != c && b != d && c != d) return 1;
  return 0;
}
int main() {
  int n, x;
  cin >> n;
  for (int i = n + 1; i < 9100; i++) {
    x = digits(i);
    if (x == 1) {
      cout << i;
      break;
    }
  }
  return 0;
}
