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