The Next Year with Distinct Digits

No attempts yetTime limit1sMemory limit128 MB

Problem

2013 is the first year since 1987 in which all digits are distinct. The years 2014, 2015, 2016, 2017, 2018, and 2019 also have all distinct digits. The year 2012, however, does not, because the digit 2 appears twice.

Given a year $Y$, find the earliest year greater than $Y$ in which every digit is distinct.

Input

The first line contains a single integer $Y$, the starting year. ($0 \le Y \le 10000$)

Output

Print the earliest year $D$ greater than $Y$ in which every digit is distinct.