Count how many points in a set have at least one point strictly above, below, to the left, and to the right of them.
Problem
You are given points on a 2D plane. A point is called supercentral if there exists at least one other point:
- with the same coordinate and a larger coordinate,
- with the same coordinate and a smaller coordinate,
- with the same coordinate and a larger coordinate,
- with the same coordinate and a smaller coordinate.
In other words, a supercentral point must have at least one point in each of the four cardinal directions: up, down, left, and right.
Your task is to determine how many points are supercentral.
Notes
- A point does not count itself.
- All points are distinct.
- Points are considered only by exact coordinate equality on one axis and strict inequality on the other.
Input Format
- The first line contains an integer .
- Each of the next lines contains two integers and , the coordinates of a point.
Output Format
Print a single integer — the number of supercentral points.
Constraints
- Coordinates are integers and fit in 32-bit signed range.
- All points are distinct.
Example 1
Input
8 0 0 1 0 -1 0 0 1 0 -1 2 2 2 1 2 3
Output
1
Explanation
Only point has a point to the left, right, above, and below it.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.