cho.sh
Notes
Loading...

Choosing Condos

Time limit

2s

Memory limit

128 MB

Problem

You want to choose condos for a trip. Ideally, a candidate should be inexpensive and close to the beach.

A condo X is a candidate only if it satisfies both conditions below.

  1. Every condo closer to the beach than X has a higher lodging cost than X.
  2. Every condo with a lower lodging cost than X is farther from the beach than X.

Given each condo's distance from the beach and lodging cost, determine how many condos can be candidates.

Input

The first line contains the number of condos N. (1 <= N <= 10000)

Each of the next N lines contains two integers D C, describing one condo. D is its distance from the beach, and C is its lodging cost. (1 <= D, C <= 10000)

No two different condos have both the same D and the same C.

Output

Print the number of condos that can be candidates.