Under construction

Still being built. Things may change

The Nearest Value to X

Interview

Time limit2sMemory limit512 MB

Summary
Given X, L, and R, print the integer in [L, R] whose absolute difference from X is smallest.
Level

Easy2 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

You are given integers X, L, and R. Among the integers between L and R inclusive, output the one whose absolute difference from X is the smallest. It can be proven that exactly one such integer exists.

Input

The input is given on standard input in the following format.

X L R

Output

Among the integers between L and R inclusive, output the one whose absolute difference from X is the smallest.

Constraints

  • 1 ≤ X ≤ 100 000.
  • 1 ≤ L ≤ R ≤ 100 000.

Examples3

  1. Example 1

    Input
    8 3 6
    
    Expected output
    6
    
  2. Example 2

    Input
    7 3 10
    
    Expected output
    7
    
  3. Example 3

    Input
    8 10 10
    
    Expected output
    10