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
from __future__ import print_function
def main():
    n = int(raw_input())
    n = n + 1
    num = []
    for i in range(4):
        num.append(n%10)
        n = n//10
    while num[3] <= 9:
        if num[3] == num[2]:
            if num[2] == 9:
                num[3] = num[3] + 1
                num[2] = 0
                num[1] = 1
                num[0] = 2
            else:
                num[2] = num[2] + 1
                num[1] = 0
                num[0] = 1
        elif num[1] == num[2] or num[1] == num[3]:
            if num[1] == 9:
                if num[2] == 9:
                    num[3] = num[3] + 1
                    num[2] = 0
                    num[1] = 1
                    num[0] = 2
                else:
                    num[2] = num[2] + 1
                    num[1] = 0
                    num[0] = 1
            else:
                num[1] = num[1] + 1
                num[0] = 0
        elif num[1] == num[0] or num[2] == num[0] or num[3] == num[0]:
            if num[0] == 9:
                if num[1] == 9:
                    if num[2] == 9:
                        num[3] = num[3] + 1
                        num[2] = 0
                        num[1] = 1
                        num[0] = 2
                    else:
                        num[2] = num[2] + 1
                        num[1] = 0
                        num[0] = 1
                else:
                    num[1] = num[1] + 1
                    num[0] = 0
            else:
                num[0] = num[0] + 1
        else:
            for i in range(4):
                print (num[3-i], end = '')
            return
main()

		  			       		 		 		   	  		