#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, c, d, k;
  cin >> n;
  n++;
  while (n > 0) {
    k = n;
    a = k % 10;
    k = k / 10;
    b = k % 10;
    k = k / 10;
    c = k % 10;
    k = k / 10;
    d = k % 10;
    if (a != b && a != c && a != d && b != c && b != d && c != d) {
      cout << n << endl;
      break;
    } else {
      n++;
      continue;
    }
  }
  return 0;
}
