You are given a string s = s_1s_2\ldots s_n of length . Find the number of its distinct substrings.
The string is generated in an unusual way. Specifically, you are given a prime number (2 \leq p \leq 10^9), and the symbol s_i corresponds to the letter with number (((p^i) \bmod (10^9+7)) \bmod 26)+1 in the English alphabet. Assume all letters in the string have the same case.
The operation a \bmod b denotes taking the remainder of dividing number by number .
The first line contains two integers and (1 \leq n \leq 10^5, 2 \leq p \leq 10^9). The number is prime.
Output a single integer — the number of distinct substrings of string .
Example 1