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.
The single line contains integer *y* (1000 ≤ *y* ≤ 9000) — the year number.
import sys


def inp():
    return int(input())


def inlt():
    return list(map(int, input().split()))


def int_to_arr():
    return list(map(int, str(input()).strip()))


def insr():
    return input().strip()


def out(x):
    sys.stdout.write(str(x) + "\n")


# def is_upper(a):
#     return ord(a) >= 65 and ord(a) <= 90


# def is_lower(a):
#     return ord(a) >= 97 and ord(a) <= 122


# def to_upper(a):
#     ans = ""
#     for i in a:
#         if ord(i) >= 97 and ord(i) <= 122:
#             ans = ans + chr(ord(i) - 32)
#         else:
#             ans = ans + i
#     return ans


# def to_lower(a):
#     ans = ""
#     for i in a:
#         if ord(i) >= 65 and ord(i) <= 90:
#             ans = ans + chr(ord(i) + 32)
#         else:
#             ans = ans + i
#     return ans


# def reverse_string(s):
#     ans = ""
#     for i in s[::-1]:
#         ans = ans + i
#     return ans


def main():
    input = inp()
    while True:
        input += 1
        digits = set([int(i) for i in str(input)])
        if len(digits) == 4:
            out(input)
            break


if __name__ == "__main__":
    main()
