#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string y;
  cin >> n;
  while (true) {
    n++;
    y = to_string(n);
    if (y[0] != y[1] && y[2] != y[3] && y[0] != y[2] && y[1] != y[3] &&
        y[0] != y[3] && y[1] != y[2]) {
      break;
    }
  }
  cout << n;
  return 0;
}
