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.
beautiful_year = []
for year in range(1000,9000):
    year_list = list(str(year))
    g = year_list[0]
    s = year_list[1]
    b = year_list[2]
    q = year_list[3]
    if g==s or g==b or g==q or s==b or s==q or b==q:
        True
    else:
        beautiful_year.append(year)

year1 = int(input())
index1 = beautiful_year.index(year1)
index2 = index1 + 1
print(beautiful_year[index2])
        
    