Combination#521

Combination

1 second
128 megabytes
Hard (≈1650)

How many numbers are divisible by the prime number p in the first n rows of Pascal Triangle? In other words, find the number of pairs (j, i) (0 ≤ j ≤ i < n) so that C(i, j) is divisible by p. Here

prb7439.gif
prb7439.gif

Input

The first line contains two integer numbers n, p (1 ≤ n ≤ 10^7, 3 ≤ p ≤ 100).

Output

Print the answer.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading