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 = int(input())
trash=[]
for first_number in '0123456789':
    for second_number in '0123456789':
        for three_number in '0123456789':
            for four_number in '0123456789':
                result=first_number+second_number+three_number+four_number
                if result[0]!='0' and result[0]!=result[1] and result[0]!=result[2] and result[0]!=result[3] and result[1]!=result[0] and result[1]!=result[2] and result[1]!=result[3] and result[2]!=result[0] and result[2]!=result[1] and result[2]!=result[3] and result[3]!=result[0] and result[3]!=result[1] and result[3]!=result[2]:
                    trash.append(int(result))
trash=sorted(trash)
for i in trash:
    if i>year:
        print(i)
        break
