|Author:||М. Спорышев, А. Кленин||Time limit:||1 sec|
|Input file:||input.txt||Memory limit:||256 Mb|
Young programmer Vasya tinkered with robots, and decided to create a new startup Delta Security with the goal of producing robot guardian to replace human guards.
As a first step, he considered a single wall and two patrolling robots moving back and forth along it.
First robot patrols a segment from L1 to R1 meters. Second robot patrols a segment from L2 to R2 meters.
At the start, each robot is located at the leftmost point of its segment and is facing to the right.
Each second, every robot checks whether it has reached the edge of its segment. In that case, robot reverses its direction. Then, robot moves exactly 1 meter in its current direction. Robots continue to patrol indefinitely. All robots move simultaneously.
You task is to determine maximum possible distance between two robots.
Robots could be located in the same position on the wall. This case doesn't affect their movements.
Input file contains integers L1 R1 L2 R2.
Output file must contain a single integer — maximum distance between robots.
0 ≤ L1 < L2 ≤ 109, 0 ≤ R1 < R2 ≤ 109
L1 < R1, L2 < R2
|No.||Input file (
||Output file (|