#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  int y, temp;
  cin >> y;
  int found = 0;
  while (true) {
    y++;
    temp = y;
    int a, b, c, d;
    a = temp % 10;
    temp /= 10;
    b = temp % 10;
    temp /= 10;
    c = temp % 10;
    temp /= 10;
    d = temp % 10;
    if (a != b && a != c && a != d && b != c && b != d && c != d) {
      found = 1;
      break;
    }
  }
  if (found == 1) cout << y << "\n";
  return 0;
}
