#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[10];
  for (int i = 0; i < 10; i++) {
    a[i] = 0;
  }
  int n;
  cin >> n;
  for (int i = n + 1; i <= 9012; i++) {
    bool flg = true;
    int r = i;
    while (r > 0) {
      a[r % 10] += 1;
      r /= 10;
    }
    for (int j = 0; j < 10; j++) {
      if (a[j] > 1) {
        flg = false;
      }
      a[j] = 0;
    }
    if (flg) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}
