eolymp
bolt
Try our new interface for solving problems

Frame

Vasil and Peter were playing in class. On the rectangular piece of paper into the cell by Vasily linyah grid draws a line parallel to one side sheet, and a frame of rectangular shape. He whispers in my ear Peter coordinates all of the segment and the coordinates of two opposite corners of the frame, and Peter tries to quickly determine the length of the segment, once inside the frame. He is bad at, and he wrote a program that does this always correct. Write to her and you.. \InputFile Let there be given through the gap \textbf{8} numbers - the coordinates of the beginning and end of the segment and the coordinates of opposite corners of the frame. Coordinates - integers, not exceeding modulo \textbf{35000}. \OutputFile Display single number - the length of the segment, which was within the frame.
Time limit 1 second
Memory limit 64 MiB
Input example #1
4 1 9 1 2 3 5 -2
Output example #1
1
Source II этап Всеукраинской олимпиады школьников 2008-2009, г. Бердичев