Problem E. Easy patrol

Author:A. Klenin, M. Sporyshev   Time limit:1 sec
Input file:input.txt   Memory limit:256 Mb
Output file:output.txt  

Statement

Young programmer Vasya tinkered with robots, and decided to create a new startup Easy Patrol with the goal of producing robot guardian to replace human guards.

As a first step, he considered a single wall of N meters in length and two patrolling robots moving back and forth along it.

First robot starts patrolling at the point located x meters from the left edge of the wall, moving to the right. Second robot starts patrolling at the point located y meters from the left edge of the wall, moving to the left.

Each second, events happen in the following order:

  1. if robots are about to collide (that is, are facing each other at the distance 0 or 1 meters), both reverse direction.
  2. each robot checks whether it has reached the edge and reverses direction if it is so.
  3. both robots move simultaneously, each for exactly 1 meter in its current direction.

Your program must determine maximum possible distance between two robots.

Input file format

Input file contains integers N, x, y.

Output file format

Output file must contain a single integer — maximum distance between robots in meters.

Constraints

4 ≤ N ≤ 106

0 ≤ x, y ≤ N

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
5 1 3
4
2
8 3 1
4

0.086s 0.011s 13