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
def add_one_to_the_index(list_of_number,index):
    if(list_of_number[index]==9):
        list_of_number[index]=0
        add_one_to_the_index(list_of_number,index-1)
    else:
        list_of_number[index]=list_of_number[index]+1
        return
def make_all_others_zero(list_of_number,index):
    global length
    for i in range(index+1,length):
        list_of_number[i]=0
def find_repeating_index(list_of_number):
    global length
    for i in range(0,length-1):
        if list_of_number[i] in list_of_number[i+1:]:
            #print(str(i)+' '+str(list_of_number[i+1:].index(list_of_number[i])+i+1))
            return i,list_of_number[i+1:].index(list_of_number[i])+i+1
    return -1,-1        
length=4
list_of_number=list(map(int,input()))
#print(list_of_number)
add_one_to_the_index(list_of_number,length-1)
#print(list_of_number)
while True:
    index1,index2=find_repeating_index(list_of_number)
    if(index1==index2==-1):
        for i in range(length):
            print(list_of_number[i],end='')
        break
    else:
        add_one_to_the_index(list_of_number,index2)
        make_all_others_zero(list_of_number,index2)
        #print(list_of_number)

