#include <bits/stdc++.h>
using namespace std;
bool digitsUnique(int year) {
  int digits[4];
  for (int i = 0; i < 4; ++i) {
    digits[i] = year % 10;
    year /= 10;
  }
  sort(digits, digits + 4);
  for (int i = 0; i < 3; ++i) {
    if (digits[i] == digits[i + 1]) {
      return false;
    }
  }
  return true;
}
int main() {
  int year, i;
  cin >> year;
  for (i = year + 1; !(digitsUnique(i)); ++i)
    ;
  cout << i;
  return 0;
}
