#include <bits/stdc++.h>
using namespace std;
string tostring(int n) {
  stringstream v;
  string x;
  v << n;
  v >> x;
  return x;
}
int main() {
  int y;
  cin >> y;
  y++;
  for (y;; y++) {
    string y1 = tostring(y);
    if (y1[0] != y1[1] && y1[0] != y1[2] && y1[0] != y1[3] && y1[1] != y1[2] &&
        y1[1] != y1[3] && y1[2] != y1[3])
      break;
  }
  cout << y << endl;
}
