From 1987 to 2013 | 프로그래밍의 벗 PivotOJ
PivotOJ

From 1987 to 2013

시간 제한: 1000ms메모리 제한: 128MB출처: CCC 2013 SeniorBOJ 6751

문제

You might be surprised to know that 2013 is the first year since 1987 with distinct digits. The years 2014, 2015, 2016, 2017, 2018, 2019 each have distinct digits. 2012 does not have distinct digits, since the digit 2 is repeated.

Given a year, what is the next year with distinct digits?

입력

The input consists of one integer Y (0 ≤ Y ≤ 10000), representing the starting year.

출력

The output will be the single integer D, which is the next year after Y with distinct digits.

예제

예제 1

입력
1987
출력
2013
코드를 제출하려면 로그인하세요.