LearnPy Hub
← Arena
EasyRating 1000

Who Gets the Last Sweet?

n prisoners sit in a circle. m sweets are handed out one by one, starting at chair s and going round. Which chair gets the last sweet?

Input

Three integers n, m, s (1 ≤ s ≤ n ≤ 10⁹, 1 ≤ m ≤ 10⁹).

Output

One integer.

Sample 1

Input
5 2 1
Output
2

Sample 2

Input
5 2 2
Output
3
solution.py
Output appears here
Who Gets the Last Sweet? · Python Arena problem · LearnPy Hub