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