jkrt does not know bit operations, so for two nonnegative integers , jkrt defines as the length of the LCS of the decimal representations of and .
Here, LCS means the longest common subsequence. For example, is a common subsequence of the decimal representations of and , and there is no longer common subsequence. Therefore,
List all positive integers satisfying
in increasing order. Let be the -th such number.
Given a positive integer , compute modulo .
Input
The input is given in the following format.
Output
Print modulo .
Constraints
- is given in decimal notation and is a positive integer.
- .
- The decimal representation of has no leading zero.
Subtasks
Samples
Sample 1
Input
1
Output
1
Since , we have .
Sample 2
Input
10
Output
10
The sequence starts with . Therefore, .
Sample 3
Input
18
Output
100
are , and the next value is .