Fence Painting#11154

Fence Painting

1 second
128 megabytes
Very easy

Several seasons of hot summers and cold winters have taken their toll on Farmer John's fence, so he decides it is time to repaint it with the help of his favorite cow, Bessie. Unfortunately, while Bessie is remarkably proficient at painting, she is not quite as good at understanding Farmer John's instructions.

If we regard the fence as a one-dimensional number line, Farmer John paints the interval from x = a to x = b. For example, if a = 3 and b = 5, then Farmer John paints an interval of length .

Bessie, having misunderstood Farmer John's instructions, paints the interval from x = c to x = d. This interval may overlap with part or all of Farmer John's interval.

Determine the total length of the fence that is covered with paint after both Farmer John and Bessie have finished painting.

Input

The first line contains two integers and b~(a < b).

The second line contains two integers and d~(c < d).

The values of a, b, c, d are all in the range , inclusive.

Output

Print one integer representing the total length of the fence covered with paint.

Examples

Example 1

Loading
Loading

Note

In the example shown, a total of units of fence are covered with paint, from x = 4 to x = 10.