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