#include <bits/stdc++.h>
using namespace std;
bool has_distinct_digits(int num) {
  map<int, bool> digits;
  while (num > 0) {
    int digit = num % 10;
    if (digits[digit]) {
      return false;
    } else {
      digits[digit] = true;
    }
    num /= 10;
  }
  return true;
}
int main() {
  int year;
  cin >> year;
  int num = year + 1;
  while (!has_distinct_digits(num)) {
    num++;
  }
  cout << num;
  return 0;
}
