#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, num;
  cin >> n;
  num = n + 1;
  while (1) {
    n = num;
    int a, b, c, d;
    a = n % 10;
    n = n / 10;
    b = n % 10;
    n /= 10;
    c = n % 10;
    n /= 10;
    d = n % 10;
    if (a != b && a != c && a != d && b != c && b != d && c != d) {
      cout << num << endl;
      break;
    }
    num++;
  }
  return 0;
}
