#abc161d. [abc161_d]Lunlun Number
[abc161_d]Lunlun Number
Problem Statement
A positive integer is said to be a lunlun number if and only if the following condition is satisfied:
- In the base ten representation of (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most .
For example, , , and are lunlun numbers, while none of , , or is.
You are given a positive integer . Find the -th smallest lunlun number.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
15
Sample Output 1
23
We will list the smallest lunlun numbers in ascending order:
, , , , , , , , , , , , , , .
Thus, the answer is .
Sample Input 2
1
Sample Output 2
1
Sample Input 3
13
Sample Output 3
21
Sample Input 4
100000
Sample Output 4
3234566667
Note that the answer may not fit into the -bit signed integer type.