#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int main() {
  ios_base::sync_with_stdio(false);
  int y;
  cin >> y;
  while (true) {
    int tem = y + 1;
    set<int> st;
    for (long long i = 0; i < 4; ++i) {
      st.insert(tem % 10);
      tem /= 10;
    }
    if (((int)(st).size()) == 4) {
      cout << y + 1;
      return 0;
    } else {
      ++y;
    }
  }
  return 0;
}
