#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(0);
  int n;
  cin >> n;
  while (true) {
    n++;
    int f = n / 1000;
    int s = n / 100 % 10;
    int t = n / 10 % 10;
    int fo = n % 10;
    if (f != s && f != t && f != fo && s != t && s != t && s != fo && t != fo)
      break;
  }
  cout << n << endl;
  return 0;
}
