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