Problem Statement
You are given two integers and .
You have the following infinite sequence \(S = [1 \small\text{ mod } \normalsize k,\ \ \ (1 + 2) \small\text{ mod }\normalsize k,\ \ \ (1 + 2 + 3) \small\text{ mod }\normalsize k,\ ... ]\), in other words \(S_i = (\sum_{j=1}^ij) \small\text{ mod }\normalsize k\).
Determine the value of , in other words, determine the value of the infinite sequence.
Input Format
Your first line will contain three space-separated integers and respectively.
Output Format
You should output a single integer , the integer of (one-indexed).
Constraints
Sample Cases
Input 1
1 10
Output 1
1
Input 2
3 10
Output 2
6
Input 3
4 10
Output 3
0
Input 4
123451234 123451234
Output 4
61725617
Template
n, k = map(int, input().split())
# print your output
Comments