A unique-digit number uses each digit from 1 to 9 at most once and never uses 0. Examples include 9, 32, 489, 98761, and 983245. Such numbers have at most 9 digits.
Given an integer N, print the smallest unique-digit number strictly greater than N. If no such number exists, print 0.
The input has several test cases. Each test case is one line with an integer N (0≤N≤999,999,999).
For each test case, print the answer on its own line. Print 0 when no valid number exists.