Teaching Hazard

No attempts yetTime limit5sMemory limit128 MB

Problem

Teaching students is fun, but it can turn embarrassing, and that is what happened to me a few days ago. It was the first meeting of a university course, so I was covering something very basic: how to count the zeroes at the end of n!n! written in base bb. The number of times a prime pp divides n!n! is

np+np2+np3+\left\lfloor \frac{n}{p} \right\rfloor + \left\lfloor \frac{n}{p^2} \right\rfloor + \left\lfloor \frac{n}{p^3} \right\rfloor + \cdots

and the same formula, used carefully, gives the number of zeroes at the end of n!n!.

After explaining it I worked out the number of trailing zeroes of 200!200! in decimal, then asked with an evil smile for the number of trailing zeroes of 100!100! in hexadecimal. I already knew the answer is 24. To my surprise a student replied 24 within minutes, so I congratulated him. A minute later I checked his script and found that he had counted the trailing zeroes of 100!100! in decimal instead of hexadecimal, and both answers happened to be 24. I was a bit embarrassed, and now I want to know why the two answers agreed.

For an integer b2b \ge 2, let Z(n,b)Z(n, b) be the number of zeroes that run backwards from the last digit of n!n! written in base bb. Given nn and xx, count the pairs (b1,b2)(b_1, b_2) with 2b1<b22 \le b_1 < b_2 such that Z(n,b1)=Z(n,b2)=pZ(n, b_1) = Z(n, b_2) = p for some integer pxp \ge x.

Input

The input has several lines. Each line contains two integers nn (1n1000001 \le n \le 100000) and xx (2x25002 \le x \le 2500), separated by a space. The last line contains two zeroes and is not processed. Excluding that line, the input has at most 1000 lines.

Output

For each line of input print the number of pairs (b1,b2)(b_1, b_2) on its own line. Every input is such that no output value exceeds 5×10185 \times 10^{18}.