#include <bits/stdc++.h>
using namespace std;
int distinct(int n) {
  int temp = n;
  int no_of_digits = 0;
  while (n > 0) {
    n /= 10;
    no_of_digits++;
  }
  int a[no_of_digits];
  int counter = 0;
  while (temp > 0) {
    a[counter] = temp % 10;
    temp /= 10;
    counter++;
  }
  for (int i = 0; i < no_of_digits; i++) {
    for (int j = i + 1; j < no_of_digits; j++) {
      if (a[i] == a[j]) {
        return -1;
      }
    }
  }
  return 1;
}
int main() {
  int n;
  cin >> n;
  for (n = n + 1; distinct(n) != 1; n++) {
  }
  cout << n;
  return 0;
}
