To help a friend who is working on the internals of the Java Virtual Machine, Luca is working on a new hash function. Hash functions are meant to take as an input a large value, process it according to internal rules, and finally produce a smaller value.
Since the number of possible different output values is limited and smaller than the number of possible input values, by using a hash function one accepts the risk of collisions. A collision happens when two distinct input values, when hashed, give the same output value.
Luca’s algorithm is rather simple, as the use case admits the possibility of collisions, provided that they don’t grow too much. The input number is a sequence of decimal digits from to : , , , . The hash is computed by multiplying each digit with the next one and reducing the result using the modulo = = , until reaching the last digit. Formally:
= (( (((() mod ) ) mod ) ) ) mod
While performing some experiments, a specific output value seems to be occurring way more often than all other values. Luca is now worried that for some reason there might be a lot of different inputs that produce exactly when hashed. How many such inputs are there?
Input data
The first line contains two integers, and .
Output data
You need to write a single line with an integer: the number of different values that produce when hashed with Luca’s algorithm. Since this number may be large, report it modulo .
Constraints and clarifications
- .
- .
# | Score | Constraints |
---|---|---|
1 | 0 | Examples |
2 | 7 | |
3 | 23 | |
4 | 8 | |
5 | 24 | |
6 | 29 | |
7 | 9 | No additional limitations. |
Example 1
stdin
1 4
stdout
1
Explanation
In the first sample case there is just one number () with digits and whose hash is .
Example 2
stdin
2 8
stdout
4
Explanation
In the second sample case, there are four numbers (, , , and ) with digits and whose hash is .