Veci

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 \le X \le 999\, 999$). 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$.

Sample Input 1 | Sample Output 1 |
---|---|

156 |
165 |

Sample Input 2 | Sample Output 2 |
---|---|

330 |
0 |

Sample Input 3 | Sample Output 3 |
---|---|

27711 |
71127 |