#include <bits/stdc++.h>
int btf(int n) {
  static int num[10];
  memset(num, 0, sizeof(num));
  for (int i = 0; i < 4; i++) {
    num[n % 10]++;
    n /= 10;
  }
  for (int i = 0; i < 10; i++)
    if (num[i] > 1) return 0;
  return 1;
}
void solve(int n) {
  for (int i = n + 1; 1; i++)
    if (btf(i)) {
      printf("%d\n", i);
      return;
    }
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) solve(n);
  return 0;
}
