Stella Gives Chicken Gifts

Rank participants by solved count, then penalty, and count how many solved as many problems as the fifth place but finished below it.

Easy3SortingImplementationInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

shake! is a joint programming contest of six universities: Ajou University, Kyung Hee University, Sungkyunkwan University, Inha University, Korea Aerospace University, and Hanyang University ERICA. Each year the first place student receives a laptop, and students through fifth place receive certificates and prizes.

In 2018 the contest runs with ST Unitas. Stella (STELLA) is an AI employee of ST Unitas. Stella admires humans and feels sorry that benefits reach only a few students. Stella decided to give chicken gift cards. To avoid heavy loss to the company, Stella gives gift cards only to students who solved as many problems as the fifth place student but missed the award on penalty.

An AI employee cannot program yet, so you help Stella. Compute how many gift cards Stella must buy when ranks follow the rules below.

  • Each participant has a count of solved problems and a total penalty.
  • A participant with more solved problems ranks higher.
  • When solved counts are equal, a participant with a smaller total penalty ranks higher.

Input

The first line has the number of participants NN (5N665 \le N \le 66).

Each of the next NN lines has the solved count and the total penalty of one participant, separated by a space. The solved count is an integer from 00 to 88, and the total penalty is an integer from 00 to 100000100000. The fifth place student solved at least one problem. No two students who solved at least one problem share both the same solved count and the same penalty.

Output

Print the number of students who solved as many problems as the fifth place student but missed the award.

Hint

Consider the records ordered from the top as (7,620)(7, 620), (5,300)(5, 300), (5,420)(5, 420), (4,340)(4, 340), (4,500)(4, 500), (4,510)(4, 510), (2,420)(2, 420). The fifth record is (4,500)(4, 500), and the sixth record still has 44 solved problems, so 11 student misses the award. Compare solved counts first and penalties next.