#include <bits/stdc++.h>
using ll = long long;
using namespace std;
bool ok(int y) {
  set<int> year;
  while (y) {
    year.insert(y % 10);
    y /= 10;
  }
  return year.size() == 4;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int y;
  cin >> y;
  y++;
  while (!ok(y)) y++;
  cout << y;
  return 0;
}
