P26766 [AtCoder] Walking Takahashi
普及
题目描述

Problem Description

Takahashi is living on a number line and is currently at coordinate $ S $. The section of the number line between coordinates $ L $ and $ R $ (inclusive) has good sunlight.

Desiring sunlight, Takahashi will repeat the following movement until his coordinate is between $ L $ and $ R $ (inclusive):

  • Let the current coordinate be $ X $. If $L \leq X \leq R$, he stops moving. If $ X $ is less than $ L $, he moves to $ X + 1 $. If $ X $ is greater than $ R $, he moves to $ X - 1 $.

Determine the coordinate where Takahashi will finally stop moving.

Input Format

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

$ S $ $ L $ $ R $

Output Format

Output the coordinate where Takahashi will finally stop moving.

Sample Input and Output

Sample Input #1

5 1 5

Sample Output #1

5

Sample Input #2

2 7 10

Sample Output #2

7

Sample Input #3

20 3 5

Sample Output #3

5

Notes/Hints

Constraints

  • $-100 \leq S \leq 100$
  • $-100 \leq L \leq R \leq 100$
  • All inputs are integers

Sample Explanation 1

Takahashi is currently at coordinate $ 5 $, which is already within the sunny section, so output $ 5 $.

Sample Explanation 2

Takahashi is currently at coordinate $ 2 $, and the sunny section is between $ 7 $ and $ 10 $ (inclusive). He will repeatedly move until he reaches $ 7 $.

Sample Explanation 3

Takahashi is currently at coordinate $ 20 $, and the sunny section is between $ 3 $ and $ 5 $ (inclusive). He will repeatedly move until he reaches $ 5 $.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 1 5
样例输出
5