When Farmer Oskar doesn’t watch his cows closely enough, they tend to wander off into the forest to hunt for horse spies. To catch an enemy agent horse, the cows lure it into a cow trail and set up fences at the endpoints of the trail, which are $L$ meters apart. Two previously hidden cows then reveal themselves, having concealed themselves in nearby bushes – and the chase is on! The cows are located at positions $A$ and $B$ meters from the left endpoint.

One particular horse (positioned $P$ meters from the left endpoint) who they attempted to catch remembered to bring her walkie-talkie and have now called for backup. The backup will arrive to rescue her very soon, so she wonders for how long she can hold the cows off.

Horse chasing happens in $1$ minute steps. During each minute, the following steps happen in order:
 - The cows choose to move either $0$ or $1$ meters, in any direction.
 - The horse jumps either $0$, $1$, or $2$ meters in any direction. However, if a cow occupies the same position as the horse, she can only jump a single meter since she now must jump over the cow.
 - If there is a cow in the same position as the horse, the cows capture her.

How long will it take for the horse to be captured, assuming both she and the cows move optimally?

-----Input-----
The first and only line of input contains four integers $1 \le L \le 1000$, $0 \le A \le L$, $0 \le B \le L$, $0 \le P \le L$ separated by spaces, the meanings of which are described in the statement.

The numbers $A$, $B$ and $P$ are all distinct.

-----Output-----
A single integer, the number of minutes before the cows can catch the horse no matter how the horse moves.

-----Examples-----
Sample Input:
5 4 3 2
Sample Output:
3

Source: kattis | Difficulty: HARD


Solutions: