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.
word = int(input())
after = word + 1
after = str(after)
after = list(map(int, after))
# print(after)

while after[0] == after[1] or after[0] == after[2] or after[0] == after[3] or after[1] == after[2] or after[1] == after[3] or after[2] == after[3]:
    after[3] += 1
    if after[3] == 10:
        after[3] = 0
        after[2] += 1
    if after[2] == 10:
        after[2] = 0
        after[1] += 1
    if after[1] == 10:
        after[1] = 0
        after[0] += 1

for i in range(len(after)):
    print(after[i], end='')
