Problem2251--Last Card

2251: Last Card

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 100100 points

Problem Statement

We will hand out a total of KK cards to NN people numbered 1, 2, \ldots, N1,2,,N.
Beginning with Person AA, we will give the cards one by one to the people in this order: A, A+1, A+2, \ldots, N, 1, 2, \ldotsA,A+1,A+2,,N,1,2,. Who will get the last card?
Formally, after Person x(1 \leq x < N)x(1x<N) gets a card, Person x+1x+1 will get a card. After Person NN gets a card, Person 11 gets a card.

Constraints

  • 1 \leq N,K \leq 10001N,K1000
  • 1 \leq A \leq N1AN
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:
NNKKAA

Output

Print a number representing the person who will get the last card.

Sample Input Copy

3 3 2

Sample Output Copy

1

HINT

The cards are given to Person 2, 3, 12,3,1 in this order.

Source/Category