Time limit: 0.1s
Memory limit: 4MB
Input: biluta.in
Output: biluta.out
Task
Luci has a small ball. This ball has an interesting property: it can move along the axis of integers! More precisely, it can only move within the interval . Luci noticed that the ball moves in the first minute by one position, in the second minute by two positions, , in the -th minute it moves positions. If it reaches one end of the interval , it changes direction and continues with the remaining number of positions.
If initially, the ball is at position and moves towards , what position will it be in after minutes?
Input data
The first line will contain the numbers and .
Output data
The first line will contain the position of the ball after minutes.
Constraints and clarifications
- ;
- ;
# | Points | Constraints |
---|---|---|
1 | 20 | , |
2 | 20 | , |
3 | 60 | No additional constraints |
Example 1
biluta.in
4 3
biluta.out
2
Explicație
The ball moves as follows:
Example 2
biluta.in
3 7
biluta.out
2
`