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 .
The input is given in the following format.
Print modulo .
Since , we have .
The sequence starts with . Therefore, .
are , and the next value is .