#include <bits/stdc++.h>
using namespace std;
int y, a, b, c, i, d;
int main() {
  cin >> a;
  for (i = a + 1; i <= 10000; i++) {
    y = i / 1000;
    b = i / 100 % 10;
    c = i / 10 % 10;
    d = i % 10;
    if (y != b && y != c && y != d && b != c && b != d && c != d) break;
  }
  cout << i;
}
