Divisors [0]


Divisors [0]

Let's consider the string of all natural numbers: 1,2,3,4,…1, 2, 3, 4, \ldots

We'd like to find the sum of the first nn values of this sequence, although that alone is a bit boring (how would we do this?)

Instead, we'd like to find the sum, only after doing a simple operation to the individual sequence values - taking their value modulo some mm.

For example, for n=5n=5, m=4m=4, the sequence of the first 5 elements would be: 1,2,3,0,11, 2, 3, 0, 1, and the total sum would be 7.

Input

Input will contain two space-separated integers nn and mm, mirroring the definition from the statement

Output

Output a single integer representing the sum of the first nn elements modulo mm.

Constraints

  • 1≤n≤1091 \leq n \leq 10^9
  • 1≤m≤1091 \leq m \leq 10^9

Example

Input 1
5 4
Output 1
7

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.