#include <bits/stdc++.h>
using namespace std;
bool yearCheck(int year) {
  vector<int> a(4);
  int i = 3;
  do {
    a[i] = year % 10;
    year /= 10;
    i--;
  } while (i >= 0);
  sort(a.begin(), a.end());
  if (binary_search(a.begin() + 1, a.end(), a[0]))
    return false;
  else if (binary_search(a.begin() + 2, a.end(), a[1]))
    return false;
  else if (binary_search(a.begin() + 3, a.end(), a[2]))
    return false;
  else
    return true;
}
int main() {
  int year;
  cin >> year;
  year++;
  while (!yearCheck(year)) {
    year++;
  }
  cout << year;
}
