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 compare(current):
	typed = []
	typed.append(int(current / 1000))
	typed.append(int((current / 100) % 10))
	typed.append(int((current / 10) % 10))
	typed.append(int(current % 10))
	y = 0
	for x in range(4):
		if typed[0] is typed[1] or typed[0] is typed[2] or typed[0] is typed[3]:
			y = y + 1
		if typed[1] is typed[0] or typed[1] is typed[3] or typed[1] is typed[2]:
			y = y + 1
		if typed[2] is typed[0] or typed[2] is typed[3] or typed[2] is typed[1]:
			y = y + 1
		if typed[3] is typed[0] or typed[3] is typed[1] or typed[3] is typed[2]:
			y = y + 1	
	return y

current = int(input())
current += 1
while(True):
	if compare(current) == False:
		print(current)
		break
	current += 1
# 1513264223111
