#include <bits/stdc++.h>
using namespace std;
bool check(int n) {
  bool flags[10] = {false};
  int cont = 0;
  while (n > 0) {
    if (!flags[n % 10]) cont++;
    flags[n % 10] = true;
    n /= 10;
  }
  return cont == 4;
}
int main() {
  int n;
  cin >> n;
  while (true) {
    n++;
    if (check(n)) break;
  }
  cout << n;
}
