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

startingYear = int(input)
thisYear = startingYear + 1

goAhead = True
while (goAhead):
    # Seting up basic conditions of the loop:
    duplicate = False  # Sets duplicate checker to False at start of loop
    # gets the length of the year we're looping through
    yrLen = len(str(thisYear))
    # turns the int into a string and then into a list.
    thisYear = list(str(thisYear))

    for i in range(yrLen):
        if thisYear.count(thisYear[i]) > 1:
            duplicate = True  # duplicate variable set to True
            # Turns thisYear from a List to an Int
            thisYear = int("".join(thisYear))
            thisYear += 1  # Add 1 to the current year in the loop.
            break
    if duplicate == False:
        goAhead = False  # turn the loop off since we found a unique number
        # print("line 29", goAhead)

output = int("".join(thisYear))

print(output)
