e-olymp
favorite We need a little bit of your help to keep things running, click on this banner to learn more
Competitions

Exponentiation

Sum of powers 2

Find the sum (11 + 22 + 33 + .... + nn) mod m.

Input

Two positive integers n and m (n, m106).

Output

Print the value of the sum modulo m.

Time limit 2 second
Memory limit 128 MiB
Input example #1
4 100
Output example #1
88
Author Michael Medvedev