#include <bits/stdc++.h>
int main() {
  int n, i, z, mil = 0, dec = 0, uni = 0, cent = 0;
  scanf("%d", &n);
  for (i = n + 1; i <= 10000; i++) {
    mil = i / 1000;
    cent = (i % 1000) / 100;
    dec = ((i % 1000) % 100) / 10;
    uni = (((i % 1000) % 100) % 10);
    if (uni != dec and uni != cent and uni != mil) {
      if (dec != cent and dec != mil) {
        if (cent != mil) {
          printf("%d", i);
          return 0;
        }
      }
    }
    mil = 0;
    dec = 0;
    uni = 0;
    cent = 0;
  }
  return 0;
}
