#ABC070B. Two Switches

Two Switches

题目描述

Alice and Bob are controlling a robot. They each have one switch that controls the robot.
Alice started holding down her button AA second after the start-up of the robot, and released her button BB second after the start-up.
Bob started holding down his button CC second after the start-up, and released his button DD second after the start-up.
For how many seconds both Alice and Bob were holding down their buttons?

爱丽丝和鲍勃正在控制一个机器人。他们各有一个控制机器人的开关。
爱丽丝在机器人启动后的第 AA 秒开始按住按钮,并在启动后的第 BB 秒松开按钮。
鲍勃在机器人启动 CC 秒后开始按住按钮,并在启动 DD 秒后松开按钮。
爱丽丝和鲍勃都按住按钮多少秒?

输入格式

AA BB CC DD

输出格式

打印 Alice 和 Bob 按住按钮的持续时间(秒)。

样例 #1

样例输入 #1

0 75 25 100

样例输出 #1

50

样例 #2

样例输入 #2

0 33 66 99

样例输出 #2

0

样例 #3

样例输入 #3

10 90 20 80

样例输出 #3

60

说明

数据规模与约定

  • 0A<B1000≤A \lt B≤100
  • 0C<D1000≤C \lt D≤100
  • 所有输入值均为整数。

样例 11 解释

爱丽丝在机器人启动后的第 00 秒开始按住按钮,并在启动后的第 7575 秒松开按钮。
鲍勃在机器人启动 2525 秒后开始按住按钮,并在启动 100100 秒后松开按钮。
因此,从启动后的 2525 秒到启动后的 7575 秒之间的 5050 秒就是他们按住按钮的时间。

样例 22 解释

爱丽丝和鲍勃没有同时按下按钮,所以答案是 0 秒。