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())
year1 = year + 1
year2 = year1
llist = []
while year1 > year:
    year2 = year1
    while year2 / 10 != 0:
        llist.append(year2 % 10)
        year2 = int(year2 / 10)
 
    zero, one, two, three, four, five, six, seven, eight, nine = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
 
    for item in llist:
        if item == 0:
            zero += 1
        if item == 1:
            one += 1
        if item == 2:
            two += 1
        if item == 3:
            three += 1
        if item == 4:
            four += 1
        if item == 5:
            five += 1
        if item == 6:
            six += 1
        if item == 7:
            seven += 1
        if item == 8:
            eight += 1
        if item == 9:
            nine += 1
 
    if zero < 2 and one <2 and two <2 and three <2 and four < 2 and five < 2 and six < 2 and seven < 2 and eight < 2 and nine < 2:
        print(year1)
        break
    year1 += 1
    llist = []