Fence Painting
Several seasons of hot summers and cold winters have taken their toll on Farmer John's fence, and he decides it is time to repaint it, along with the help of his favorite cow, Bessie. Unfortunately, while Bessie is actually remarkably proficient at painting, she is not as good at understanding Farmer John's instructions.
If we regard the fence as a one-dimensional number line, Farmer John paints the interval between and . For example, if and , then Farmer John paints an interval of length . Bessie, misunderstanding Farmer John's instructions, paints the interval from to , which may possibly overlap with part or all of Farmer John's interval. Please determine the total length of fence that is now covered with paint.
Input
The first line contains the integers and .
The second line contains integers and .
The values of and all lie in the range , inclusive.
Output
Print a single line containing the total length of the fence covered with paint.
Examples
Note
Here, total units of fence are covered with paint, from all the way through .