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
# Design_by_JOKER

import math
import cmath
from decimal import *  # su dung voi so thuc
from fractions import *  # su dung voi phan so


# getcontext().prec = x # lay x-1 chu so sau giay phay ( thuoc decimal)
# Decimal('12.3') la 12.3 nhung Decimal(12.3) la 12.30000000012
# Fraction(a) # tra ra phan so bang a (Fraction('1.23') la 123/100 Fraction(1.23) la so khac (thuoc Fraction)
# a = complex(c, d) a = c + d(i) (c = a.real, d = a.imag)
# a.capitalize() bien ki tu dau cua a(string) thanh chu hoa, a.lower() bien a thanh chu thuong, tuong tu voi a.upper()
# a.swapcase() doi nguoc hoa thuong, a.title() bien chu hoa sau dau cach, a.replace('a', 'b', slg)
# a.join['a', 'b', 'c'] = 'a'a'b'a'c, a.strip('a') bo dau va cuoi ki tu 'a'(rstrip, lstrip)
# a.split('a', slg = -1) cat theo ki tu 'a' slg lan(rsplit(), lsplit()), a.count('aa', dau = 0, cuoi= len(a)) dem slg
# a.startswith('a', dau = 0, cuoi = len(a)) co bat dau bang 'a' ko(tuong tu endswith())
# a.find("aa") vi tri dau tien xuat hien (rfind())
# input = open(".inp", mode='r')  a = input.readline()
# out = open(".out", mode='w')

n = int(input()) + 1
a = [0] * 4
while 1:
    a[0] = n //1000
    a[1] = (n-a[0]*1000)//100
    a[2] = (n - a[0]*1000 - a[1] * 100)//10
    a[3] = n % 10
    s, ok = [], 1
    for i in range(4):
        if a[i] in s:
            n += 1
            ok = 0
            break
        s.append(a[i])
    if ok:
        break

print(n)
