It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits.

Now you are suggested to solve the following problem: given a year number, find the minimum year number which is strictly larger than the given one and has only distinct digits.
The single line contains integer *y* (1000 ≤ *y* ≤ 9000) — the year number.
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop, heapify
from math import *
from collections import defaultdict, Counter, deque
from functools import lru_cache
from sys import stdin, stdout
import random
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
RANDOM = random.randrange(2**62)
ninput = lambda: int(input())
sinput = lambda: input().decode().strip() 
ainput = lambda: list(map(int, input().split()))
printt = lambda *x: stdout.write(" ".join(map(str, x)) + '\n')
ceil = lambda a, b: a // b if (a >= 0) ^ (b > 0) else (abs(a) + abs(b) - 1) // abs(b)
Wrapper = lambda x: x ^ RANDOM

t = 1
for _ in range(t):
    n = ninput()
    for i in range(n+1, 9001):
        if len(set(j for j in str(i))) == 4: printt(i); break
