P25400 [AtCoder] Swimming
普及
题目描述

Problem Description

There is a pool with a length of $ L $ meters.

Lars starts swimming from the left end of the pool and repeatedly swims to the end and then turns back to swim in the opposite direction.

When Lars has swum $ X $ meters, how far is he from the left end of the pool?

Input Format

The input is given from the standard input in the following format:

$ L $ $ X $

Output Format

Output a single line with the distance from the left end of the pool where Lars is after swimming $ X $ meters.

Sample Input and Output

Sample Input #1

25 80

Sample Output #1

20

Sample Input #2

50 100

Sample Output #2

0

Sample Input #3

20 15

Sample Output #3

15

Notes/Hints

Constraints

  • All inputs are integers.
  • $1 \leq L \leq 100$
  • $1 \leq X \leq 1000$

Sample Explanation 1

Lars's actions are as follows:
- Swims 25 meters from the left end to the right end.
- Turns and swims 25 meters from the right end to the left end.
- Turns and swims 25 meters from the left end to the right end.
- Turns and swims 5 meters from the right end.
At this point, Lars is 20 meters from the left end.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
25 80
样例输出
20