#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  n++;
  while (1) {
    vector<bool> a(10, 0);
    a[n / 1000] = 1;
    a[n / 100 % 10] = 1;
    a[n / 10 % 10] = 1;
    a[n % 10] = 1;
    int sum = 0;
    for (int i = 0; i <= 9; i++) sum += a[i];
    if (sum == 4) break;
    n++;
  }
  cout << n;
}
