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
# n = int(raw_input())
# a = int(n ** 0.5) + 1
# if n == 1:
#     print "not prime"
# if n % 2 == 0:
#     print "not prime"
# else:
#     for i in xrange(3, a + 1, 2):
#         if n % i == 0:
#             print "not prime"
#             exit(0)
#     print "prime"
# a = int(raw_input())
# b = int(raw_input())
# c = b % a
# while c > 0:
#     a = c
#     b = a
#     c = b % a
# print a
# n = int(raw_input())
# a = int(n ** 0.5)
# if a ** 2 != n:
#    a += 1
# b = 0
# c = 0
# if n == 1:
#     print "1"
#     exit(0)
# if a ** 2 == n:
#    c = 1
# for i in xrange(1, a, 1):
#    if n % i == 0:
#        b += 1
# print 2 * b + c
# for i in range(1,5):
#    print i * "a"
# for i in range(1,5):
#    print (5-i) * "a"
# for i in range (1,5):
#    print i * " " + (5-i) * "a"
# for i in range (1,5):
#    print (5-i) * " " + i * "a"
# n = int(input())
# numbers = list(map(int, input().split()))
# e = numbers[0]
# a = 0
# b = 0
# for i in numbers:
#    c = i
#     if e > c:
#         b = e % c
#         a = c
#     if c < e:
#         b = c % e
#         a = e
#     while a != 0 and b != 0:
#         d = a
#         b = a % b
#         a = d
#     if a != b:
#         e = a + b
# print(e)
# n = int(input())
# a = 0
# b = 1
# c = 1
# for i in range(n):
#     c = a + b
#     a = b
#     b = c
# print(c)

# def get(n):
#     if n == 1:
#         return 1
#     elif n == 2:
#         return 2
#     else:
#         return get(n - 1) + get(n - 2)


# n = int(input())
# print(get(n))

# n = int(input())
#
# dp = [0] * (n + 1)
#
#
# def get(n):
#     if dp[n] != 0:
#         return dp[n]
#     if n == 1:
#         return 1
#     elif n == 2:
#         return 2
#     else:
#         dp[n] = get(n - 1) + get(n - 2)
#         return dp[n]
#
#
# print(get(n))
# n = int(input())
# a = 0
# for i in range(1, n // 2 + 1):
#     if (n - i) % i == 0:
#         a += 1
# print(a)
# n = int(input())
# if n % 2 == 0:
#     print("Mahmoud")
# else:
#     print("Ehab")
# n,m = list(map(int, input().split()))
# array = list(map(int, input().split()))
# b = [0 for i in range(n)]
# for i in array:
#     b[i-1] += 1
# c = 1001
# for i in b:
#     if c > i:
#         c = i
#  print(c)
# n,m = list(map(int, input().split()))
# if n > 2.71828182846 and m > 2.71828182846:
#     if n > m:
#         print(">")
#     else:
#         print("<")
# else:
#     if n > m:
#         print("<")
#     else:
#         print(">")

#
# n = list(map(int, input().split()))
# array = list(map(int, input().split()))
# c = 0
# for i in range(len(array)):
#     if array[i] != 0:
#         a = i + 1
#         b = i
#         while b != a:
#             d = array[b]
#             array[b] = 0
#             b = array[d-1]
#         c += 1
# print(c)

# n = list(map(int, input().split()))
# array = list(map(int, input().split()))
# a = 1000000001
# amount = 0
# for i in range(len(array)):
#     c = array[n - i - 1]
#     if c < a:
#         amount = amount + c
#         a = c
#     elif c > a:
#         amount = amount + a - 1
#         a = a - 1
#
# print (amount)



n = int(input())
while 1 == 1:
    a = str(n + 1)
    n = n + 1
    if a[0] != a[1] and a[0] != a[2] and a[0] != a[3] and a[1] != a[2]and a[2] != a[3] and a[1] != a[3]:
        print (n)
        break


