F. Navigation Puzzle
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Stelle is in Xianzhou Luofu and needs to call a taxi. However, before one can call a taxi, they must solve a simple puzzle.

The puzzle consists of a ring with $$$n$$$ ($$$1 \le n \le 10^9$$$) points on its circumference. These points are labelled from $$$1 \dots n$$$. On these points, there are three movable objects. In one move, Stelle can choose any one of these movable objects and move it either one point counterclockwise or one point clockwise, and the taxi will be called once all objects reach the same position.

Since Stelle is in a hurry, she now wants you to find the minimum number of moves she needs to call the taxi.

Input

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^9$$$), denoting the number of points on the circumference on the circle.

The second line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$ ($$$1 \le a, b, c, \le n$$$), denoting that the first movable object is at point $$$a$$$, the second one is at point $$$b$$$, and the third one is at point $$$c$$$.

Output

Output a single integer denoting the minimum number of moves needed to move all of the movable objects to the same point.

Examples
Input
6
1 3 5
Output
4
Input
5
1 1 5
Output
1