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
# 1 задача
# a = set(map(int, input().split()))
# b = set(map(int, input().split()))
# print(*sorted(list(a & b)))

# # 2 задача
# a = set(map(int, input().split()))
# b = set(map(int, input().split()))
# print(*sorted(list(a - b)))


# # 3 задача
# A. Девушка или Юноша
# n = input()
# length_str = len(set(n))
# print('CHAT WITH HER!' if length_str % 2 == 0 else 'IGNORE HIM!')
# https://codeforces.com/problemset/problem/236/A


# # 4 задача A. Не смешите мои подковы
# print(4-len(set(input().split())))
# https://codeforces.com/problemset/problem/228/A

# # 5 задача A. Почти счастливое число
# n = input()
# print('YES' if n.count('4') + n.count('7') == 7 or
#                n.count('4') + n.count('7') == 4 else 'NO')
# https://codeforces.com/problemset/problem/110/A

# # 5 задача A. Красивый год
n = input()
for i in range(int(n)+1, int(n)+1000):
    if len(set(str(i))) == 4:
        print(i)
        break
# https://codeforces.com/problemset/problem/271/A