Swords
InterviewTime limit1sMemory limit1024 MB
Count the swords that no other sword matches or beats in both attack and defence.
Problem
Yan Hao has swords numbered from 1 to . Sword has attack and defence .
Yan Hao considers sword useless if there is a different sword () such that and . In other words, sword is useless when another sword matches or beats it in both attack and defence. A sword that is not useless is useful.
Two swords are equivalent if they have the same attack and the same defence. No two swords are equivalent.
Find the number of useful swords.
Input
The first line contains one integer .
Each of the next lines contains two space-separated integers. The -th of these lines contains and , the attack and defence of sword .
Output
Print one integer, the number of useful swords.
Constraints
- For all , or .