#include <bits/stdc++.h>
using namespace std;
int main() {
  int year, a = 1, b = 1, c = 1, d = 1;
  cin >> year;
  while (a == b || a == c || a == d || b == c || b == d || c == d) {
    year++;
    a = year / 1000;
    b = (year / 100) % 10;
    c = (year / 10) % 10;
    d = year % 10;
  }
  cout << year;
  return 0;
}
