#include <bits/stdc++.h>
int main() {
  int x;
  scanf("%d", &x);
  while (!0) {
    x += 1;
    int a = x / 1000;
    int b = (x / 100) % 10;
    int c = (x / 10) % 10;
    int d = x % 10;
    if (a != b && a != c && a != d && a != d && b != c && b != d && c != d)
      break;
  }
  printf("%d", x);
  return 0;
}
