Rectangles
Easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
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 0.21626 seconds, how much time a human needs?
Input
The only line contains eight integers, separated by spaces: x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4. All integers are not negative, less than 1000. It is guaranteed that x_1 < x_2, y_1 < y_2, x_3 < x_4, y_3< y_4.
Output
The only line at output should contain an answer: number of intersection points. If number of such point is infinite, you should output "–1".
Examples
Input #1
Answer #1
Submissions 424
Acceptance rate 13%