Time limit
2s
Memory limit
128 MB
Call a positive integer X an equal-digit-count number if every digit that appears in the decimal representation of X appears the same number of times. Digits that do not appear are ignored. For instance, 2013 satisfies this condition because every appearing digit occurs once, while 2008 does not because 0 occurs twice and 2 and 8 occur once.
Given a natural number N, find the smallest equal-digit-count number that is greater than or equal to N.
The first line contains a natural number N. N is at most 10^18.
Print the answer on the first line. The answer is at most 9,223,372,036,854,775,807.