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.
n=int(input())
n=n+1
r=n
d1=0
d2=0
d3=0
d4=0
while True:
    d4=n%10
    n=int(n/10)
    d3=n%10
    n=int(n/10)
    d2=n%10
    n=int(n/10)
    d1=n%10
    if d1==d2 or d1==d3 or d1==d4 or d2==d3 or d2==d4 or d3==d4:
        r=r+1
        n=r
    else:
        print(r)
        break