Given the equation of the form X^N + Y^N \equiv Z^N \pmod{M}.
For fixed and , find the number of different solutions to this equation. A solution is defined as a triple of positive integers (X, Y, Z), which satisfies:
1 \leq X \leq Y < M
1 \leq Z < M
X^N + Y^N \equiv Z^N \pmod{M}
The input file contains a single line with the numbers and (1 \leq N, M \leq 7^7).
The output file should contain a single number — the answer to the problem.
Example 1