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.
gads = input()
gads_org = gads
while True:
    gads = str(gads)
    z = gads[0]
    x = gads[1]
    c = gads[2]
    v = gads[3]
    if z != x and z != c and z != v and x != c and x != v and c !=v:
        if gads > gads_org:
            print(gads)
            break
        else:
            gads = int(gads) + 1
    else:
        gads = int(gads) + 1
    