Problems
Rectangles
Rectangles
Little rabbit Stew has received has first homework. Is it is very simple: having two rectangles, find numbers of points where boundaries of these rectangles intersect. Rectangles are represented by coordinates of their bottom left and top right corners, sides are parallel to the coordinate axis.
Rabbit Stew solved this problem in \textbf{0.21626} seconds, how much time a human needs?
\InputFile
The only line contains eight integers, separated by spaces: \textbf{x_1}, \textbf{y_1}, \textbf{x_2}, \textbf{y_2}, \textbf{x_3}, \textbf{y_3}, \textbf{x_4}, \textbf{y_4}. All integers are not negative, less than \textbf{1000}. It is guaranteed that \textbf{x_1} < \textbf{x_2}, \textbf{y_1} < \textbf{y_2}, \textbf{x_3} < \textbf{x_4}, \textbf{y_3}< \textbf{y_4}.
\OutputFile
The only line at output should contain an answer: number of intersection points. If number of such point is infinite, you should output "\textbf{--1}".
Input example #1
4 5 6 7 6 7 8 9
Output example #1
1