Олимпиадный тренинг

Задача 38583. Two buttons


Alice and Bob control the robot. Each of them has one button that controls the robot. Alice started holding the button A seconds after starting the robot and released the button  B seconds after trigger. Bob started holding the button seconds after trigger and released the button after D seconds after trigger.  How many seconds did Alice and Bob hold their buttons at the same time?

Input
Input 4 integers: A, B, C and (\(1<=A<B<=100\)\(1<=C<D<=100\) ).

Imprint
Print the length of time (in seconds) that Alice and Bob held their buttons simultaneously.
 

 

Examples
# Input Output Explanations
1 0 75 25 100 50 Alice started holding the button 0 seconds after the robot started and released it 75 seconds after it started.
Bob started holding the button 25 seconds after launch and released it 100 seconds after launch.
Therefore, the time they both held down their buttons is 50 seconds from 25 seconds after launch to 75 seconds after launch.
2 0 33 66 99 0 Alice and Bob didn't hold down the buttons at the same time, so the answer is zero seconds.
3 10 90 20 80 60