#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  while (1) {
    n++;
    int x = n;
    bool f = 0;
    map<int, bool> vis;
    while (x) {
      int a = x % 10;
      if (!vis[a])
        vis[a] = 1;
      else {
        f = 1;
        break;
      }
      x /= 10;
    }
    if (!f) {
      cout << n << "\n";
      return 0;
    }
  }
  return 0;
}
