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
import sys

local_launch = False
try:
    open('LOCAL').read()
    local_launch = True
except:
    pass
input_data = open('INPUT.txt').read() if local_launch else sys.stdin.read()
done = {'i': 0}
tokens = input_data.split()

def next_token():
    result = tokens[done['i']]
    done['i'] += 1
    return result

def next_int():
    return int(next_token())

def next_str():
    return next_token()

############## BEGIN OF CODE #####################
n = next_int()
z = n+1
def is_pretty(n):
    count = 0
    a = n % 10
    b = (n // 10) % 10
    c = (n // 100) % 10
    e = (n // 1000) % 10
    if a == b or a == c or a == e:
        count += 1

    if b == c or b == e:
        count += 1

    if c == e:
        count += 1

    if count > 0:
        return False
    else:
        return True
while not is_pretty(z):
    z=z+1
print(z)
# на вход число
# сказать хорошее или плохое число


############# END OF CODE #####################