We say a base-k real number is beautiful if the decimal part of the real number is purely cyclic.
Now we want to know given base-10 numbers n,m, how many distinct (in value) purely cyclic real numbers there are that can be represented by yx where 1≤x≤n,1≤y≤m, and x,y are integers.
A real number is said to be purely cyclic if and only if it can be written in the form of a.c_1˙c_2c_3…c_p−1c_p˙ where a is an (base-k) integer, p≥1, and for 1≤i≤p, c_i is a digit in base k.
For example, under base 10, 0.45454545⋯=0.4˙5˙ is purely cyclic and can be represented by 115 or 2210. Under base 10, 0.166666⋯=0.16˙ is not purely cyclic but can be represented by fractions like 61.
Attention: an integer is purely cyclic since its decimal part can be written as repeating 0s or repeating k−1s. A terminating decimal whose decimal part is non-zero is not considered to be purely cyclic.
Notes: In China, the repeating part of a repeating decimal is marked by one or two dots. In some countries, the repeating part is marked by a line above the repeating part.
The input consists of one line with three base-10 integers n,m,k whose meanings are described in the problem description.
Output a line with an integer denoting the beautiful numbers satisfying all the constraints.
For all test cases, 1≤n≤109,1≤m≤109,2≤k≤2000.