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.
year = input()

yearList = []
check = True
yearNum = int(year)

while check:
    for x in year:
        yearList.append(x)
    times = len(yearList) - 1
    z = 1
    for x in range(len(yearList) - 1):
        for y in range(times):
            if yearList[x] == yearList[y + z]:
                check = False
                break
        if not check:
            check = True
            yearList.clear()
            yearNum = yearNum + 1
            year = str(yearNum)
            break
        times = times - 1
        z = z + 1
        if times == 0:
            check = False
            break


print(year)
