A repetition-free number is one in which each digit 1,2,3, ... ,9
appears at most once and the digit 0 does not appear.
A repetition-free number can have at most nine digits, but may also have fewer than nine digits.
Some examples of repetition-free numbers are 7
, 46
, 526
, 98543
and 756891
.
You will be given an integer N
with at most nine digits. Your task is to print out the smallest repetition-free number bigger than N
.
For example, for 98
the answer is 123
, for 769
the answer is 791
, and for 533
the answer is 534
.
Input format
A single line with a single integer with at most 9
digits.
Output format
A single line containing the smallest repetition-free number bigger than the given number. If there is no repetition-free number bigger than the given number, print 0
.