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