PivotOJ

VECI

시간 제한: 1000ms메모리 제한: 128MB출처: COCI 2007-2008BOJ 2992

문제

Your program will be given an integer X. Find the smallest number larger than X consisting of the same digits as X. 

입력

The first line of input contains the integer X (1 ≤ X ≤ 999999). 

The first digit in X will not be a zero. 

출력

Output the result on a single line. If there is no such number, output 0. 

 

예제

예제 1

입력
156
출력
165

예제 2

입력
330
출력
0

예제 3

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