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.

Input

The single line contains integer y (1000 ≤ y ≤ 9000) — the year number.

Output

Print a single integer — the minimum year number that is strictly larger than y and all it's digits are distinct. It is guaranteed that the answer exists.

Examples

Input

1987


Output

2013


Input

2013


Output

2014
year= int(input())
year0 = str(year)
none= True
while none:
    year+=1
    year0 = str(year)
    a=0
    b=0
    c=0
    d=0
    e=0
    f=0
    g=0
    h=0
    i=0
    j=0
    for k in range(4):
        if year0[k]=="0":
            a+=1
        elif year0[k]=="1":
            b+=1
        elif year0[k]=="2":
            c+=1
        elif year0[k]=="3":
            d+=1
        elif year0[k]=="4":
            e+=1
        elif year0[k]=="5":
            f+=1
        elif year0[k]=="6":
            g+=1
        elif year0[k]=="7":
            h+=1
        elif year0[k]=="8":
            i+=1
        elif year0[k]=="9":
            j+=1
    if a<=1 and b<=1 and c<=1 and d<=1 and e<=1 and f<=1 and g<=1 and h<=1 and i<=1 and j<=1:
        none = False
        print(year)