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