#include <bits/stdc++.h>
using namespace std;
int main() {
  int num, res;
  cin >> num;
  res = ++num;
  while (true) {
    num = res;
    int n1 = num % 10;
    num /= 10;
    int n2 = num % 10;
    num /= 10;
    int n3 = num % 10;
    num /= 10;
    int n4 = num % 10;
    if ((n1 == n2) || (n1 == n3) || (n1 == n4) || (n2 == n3) || (n2 == n4) ||
        (n3 == n4))
      ++res;
    else
      break;
  }
  cout << res << endl;
  return 0;
}
