#include <bits/stdc++.h>
using namespace std;
bool isBeautiful(int n) {
  bool flag[10];
  for (int i = 0; i < 10; i++) flag[i] = false;
  while (n > 0) {
    int digit = n % 10;
    if (flag[digit]) return false;
    flag[digit] = true;
    n = n / 10;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  if (isBeautiful(n)) n++;
  while (!isBeautiful(n)) {
    n++;
  }
  cout << n;
  return 0;
}
