#include <bits/stdc++.h>
int main() {
  float x;
  int y, z, h, i;
  scanf("%f", &x);
  if (x >= 1000 && x <= 9000 && (int)x - x == 0) {
    x++;
    y = x / 1000;
    z = (x / 100) - (10 * y);
    h = (x / 10) - (100 * y) - (10 * z);
    i = (int)x % 10;
    while (y == z || y == h || y == i || z == h || z == i || h == i) {
      x++;
      y = x / 1000;
      z = (x / 100) - (10 * y);
      h = (x / 10) - (100 * y) - (10 * z);
      i = (int)x % 10;
    }
    printf("%.0f", x);
  } else
    printf("Error");
  return 0;
}
