题目描述
Problem Description
Given a positive integer $x$, find the smallest number $y$ such that the occurrences of digits $0$ through $9$ in $y$ match those in $x$, and $x < y$.
Input Format
The input consists of a single line containing an integer, representing $x$.
Output Format
Output a single integer representing the answer. If such a $y$ does not exist, output $0$.
Sample Input and Output
Sample Input #1
156
Sample Output #1
165
Sample Input #2
330
Sample Output #2
0
Sample Input #3
27711
Sample Output #3
71127
Notes
Data Size and Constraints
For all test cases, it is guaranteed that $1 \leq x < 10^6$.
Notes
This problem is translated from COCI2007-2008 CONTEST #4 T2 VECI.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分
样例输入
156
样例输出
165