#P1205E. Expected Value Again
Expected Value Again
No submission language available for this problem.
Description
You are given integers , . Let's consider the alphabet consisting of different elements.
Let beauty of the string be the number of indexes , , for which prefix of of length equals to suffix of of length . For example, beauty of the string equals , as for prefix and suffix of length are equal.
Consider all words of length in the given alphabet. Find the expected value of of a uniformly chosen at random word. We can show that it can be expressed as , where and are coprime and isn't divided by . Output .
The first and the only line contains two integers , (, ) — the length of a string and the size of alphabet respectively.
Output a single integer — .
Input
The first and the only line contains two integers , (, ) — the length of a string and the size of alphabet respectively.
Output
Output a single integer — .
Samples
Note
In the first example, there are words of length in alphabet of size — , , , , , , , , . of them have beauty and of them have beauty , so the average value is .
In the third example, there is only one such word, and it has beauty , so the average value is .