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.
ano = int(input(""))
if ano<1000 or ano>9000:
    exit(1)
achouUnico = i = j = 0
while achouUnico != 1:
    ano = ano + 1
    strano = str(ano)
    numeroDuplo = 0
    i = 0
    while i < len(strano) and numeroDuplo!=1:
        numeroDuplo = 0
        j=0
        while j < len(strano) and numeroDuplo!=1:
            #print( i, j, '[i]=',strano[i],' [j]=',strano[j], len(strano), achouUnico, ano)
            if strano[i] == strano[j] and i != j:
                #print('entrei',i, j, strano[i], strano[j], len(strano), achouUnico, ano)
                numeroDuplo = 1
            j = j + 1
        i = i + 1
    if (i == len(strano) and j == len(strano) and i==j) :
        achouUnico = 1
print(ano)