Problem2379-- ABC261a - Intersection

2379: ABC261a - Intersection

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description

Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 100100 points

我们有一条数字线。高桥画了这条线的一些部分,如下所示:

首先,他将X=L1 到 X=R1的部分涂成红色。

接下来,他将从X=L2到X=R2的部分涂成蓝色。

找出同时被绘制为红色和蓝色的线条部分的长度。

Problem Statement

We have a number line. Takahashi painted some parts of this line, as follows:
  • First, he painted the part from X=L_1X=L1 to X=R_1X=R1 red.
  • Next, he painted the part from X=L_2X=L2 to X=R_2X=R2 blue.
Find the length of the part of the line painted both red and blue.

Constraints

  • 0\leq L_1<R_1\leq 1000L1<R1100
  • 0\leq L_2<R_2\leq 1000L2<R2100
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:
L_1L1R_1R1L_2L2R_2R2

Output

Print the length of the part of the line painted both red and blue, as an integer.

Sample Input Copy

0 3 1 5

Sample Output Copy

2

HINT

The part from X=0X=0 to X=3X=3 is painted red, and the part from X=1X=1 to X=5X=5 is painted blue.

Thus, the part from X=1X=1 to X=3X=3 is painted both red and blue, and its length is 22.

Source/Category