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.
a=input()
d=""
if a[1]=="9":
    k=int(a[0])+1
    d+=str(k)
    d+="01"
    if k==3:
        d+="4"
    else:
        d+="3"
else:
    d+=a[0]
    if a[2]=="9":
        m=int(a[1])+1
        d+=str(m)
        d+="0"
        for i in range(1,10):
            if i!=m and i!=int(a[0]):
                d+=str(i)
                break
    else:
        d+=a[1]
        if a[3]=="9":
            n=int(a[2])+1
            d+=str(n)
            d+="0"
        else:
            d+=a[2]
            for i in range(1,10):
                if i!=int(a[1]) and i!=int(a[0]) and i!=int(a[2]):
                    d+=str(i)
                    if int(d)>int(a):
                        break
                    else:
                        j=d
                        for w in range(1,10):
                            if w!=int(a[1]) and w!=int(a[0]) and w!=int(a[2]) and w!=int(a[3]):
                                r=w-int(a[3])
                                break
                        d=str(int(j)+r)
                        break
print(str(d))                
                