Rectangles#3218

Rectangles

1 second
64 megabytes
Easy

Little rabbit Stew has received his first homework. The task is very simple: given two rectangles, find the number of points where their boundaries intersect. The rectangles are given by the coordinates of their bottom-left and top-right vertices, and their sides are parallel to the coordinate axes.

Rabbit Stew solved this problem in 0.21626 seconds. How long would it take a human?

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 non-negative and less than . It is guaranteed that x_1 < x_2, y_1 < y_2, x_3 < x_4, y_3 < y_4.

Output

Print a single integer: the number of intersection points of the rectangles' boundaries. If there are infinitely many such points, print "–1".

Examples

Example 1

Loading
Loading