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 binary_search(arr, low, high, x): 
  
    # Check base case 
    mid = (high + low) // 2
    if high >= low: 
  
  
        # If element is present at the middle itself 
        if arr[mid] == x: 
            return mid 
  
        # If element is smaller than mid, then it can only 
        # be present in left subarray 
        elif arr[mid] > x: 
            return binary_search(arr, low, mid - 1, x) 
  
        # Else the element can only be present in right subarray 
        else: 
            return binary_search(arr, mid + 1, high, x) 
  
    else: 
        # Element is not present in the array 
        return mid
a=[]
for i in range(1000,9001):
    if(len(set(str(i)))==len(str(i))):
        a.append(i)
n=int(input())
a.append(9012)
if(n<a[0]):
    print(a[0])
    
else:
    s=binary_search(a,0,len(a)-1,n)
    for i in range(s,len(a)):
        if(a[i]>n):
            print(a[i])
            break
        
    

