#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T a) {
  return a * a;
}
bool ok(int a) {
  int was[200] = {0};
  while (a) {
    int k = a % 10;
    a /= 10;
    if (was[k]) return 0;
    was[k] = 1;
  }
  return 1;
}
int main() {
  int a;
  cin >> a;
  for (int i = a + 1;; ++i) {
    if (ok(i)) {
      cout << i;
      return 0;
    }
  }
  return 0;
}
