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