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 $X$ ($1 \le X \le 999999$). The first digit in $X$ will not be a zero.

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

-----Examples-----
Sample Input 1:
156
Sample Output 1:
165

Sample Input 2:
330
Sample Output 2:
0

Source: kattis | Difficulty: EASY
Tags: Complete search


Solutions: