Simple Rectangles

Time limit1sMemory limit128 MB

Problem

Cheolsu starts from one point on grid paper and draws along grid lines, alternating between horizontal and vertical directions. The drawing is complete when he returns to the starting point.

The drawing consists of vertical and horizontal segments and satisfies the following conditions.

  1. Different segments may cross. However, two vertical segments or two horizontal segments never touch or intersect each other.
  2. Each endpoint of every segment is connected to exactly one other segment.

These segments form several polygons whose corners are all right angles. Among them, call a region a simple rectangle if its shape is a rectangle and its interior contains no segment.

In the figure below, the drawing consists of 16 segments. It creates 3 simple rectangles: B, C, and E. The combined region C, D, and E is also rectangular, but it contains a segment inside, so it is not a simple rectangle.

Write a program that counts the number of simple rectangles made by the drawing.

Input

The first line contains an integer N (4 ≤ N ≤ 1000), the number of vertices.

Each of the next N lines contains two integers x and y (0 ≤ x, y ≤ 10,000), the coordinates of one vertex. x is the X-coordinate and y is the Y-coordinate.

The vertices are given in drawing order, and the last vertex is connected back to the first vertex.

Output

Print the number of simple rectangles on the first line. If there is no simple rectangle, print 0.