Hide
Problem D
Veci
Your program will be given an integer X. Find the smallest number larger than X consisting of the same digits as X.
Input
The first line of input contains the integer
Output
Output the result on a single line. If there is no such
number, output
Sample Input 1 | Sample Output 1 |
---|---|
156 |
165 |
Sample Input 2 | Sample Output 2 |
---|---|
330 |
0 |
Sample Input 3 | Sample Output 3 |
---|---|
27711 |
71127 |