#K85422. Hot Potato Game

    ID: 36638 Type: Default 1000ms 256MiB

Hot Potato Game

Hot Potato Game

In the Hot Potato Game, there are \(n\) players arranged in a circle and numbered from 1 to \(n\). Starting from player \(k\), the potato is passed \(m\) times clockwise. Since the players are seated in a circle, the count wraps around when it exceeds \(n\).

The final player holding the potato can be determined using the formula:

\(\text{final\_position} = ((k - 1 + m) \mod n) + 1\)

Your task is to compute the final player number who will hold the potato after \(m\) passes.

inputFormat

The input consists of a single line with three space-separated integers \(n\), \(k\), and \(m\), where:

  • \(n\) (2 ≤ n ≤ 106) is the total number of players.
  • \(k\) (1 ≤ k ≤ n) is the starting player's number.
  • \(m\) (0 ≤ m ≤ 109) is the number of passes.

outputFormat

Output a single integer: the number of the player who ends up holding the potato after \(m\) passes.

## sample
5 2 3
5