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=input()
d1=int(year[0])
d2=int(year[1])
d3=int(year[2])
d4=int(year[3])

d4=int(d4+1)
if int(d4)==int(10):
    d4=int(0)
    d3=int(d3+1)
if int(d3)==int(10):
    d3=0
    d2=int(d2+1)
if int(d2)==int(10):
    d2=0
    d1=int(d1+1)
        
while ((d1==d2) or (d1==d3) or (d1==d4) or (d2==d3) or (d2==d4) or (d3==d4)):
   
    d4=d4+1
        
    if int(d4)==int(10):
        d4=int(0)
        d3=int(d3+1)
    if int(d3)==int(10):
        d3=0
        d2=int(d2+1)
    if int(d2)==int(10):
        d2=0
        d1=int(d1+1)
        

print(str(d1)+str(d2)+str(d3)+str(d4))
