There are n points on the plane. All points have distinct x-coordinates and distinct y-coordinates (no two points share the same x-coordinate, and no two points share the same y-coordinate).
Two points are called friendly when the axis-aligned rectangle that has these two points as opposite corners contains no other point strictly inside it. Count how many friendly pairs of points there are.
The first line contains the number of points n (1≤n≤105). Each of the next n lines contains the coordinates x and y (0≤x,y≤106) of one point, separated by a space.
Print a single integer: the number of friendly pairs of points.