Cow Contest
cows, numbered from to , participate in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is unique among the competitors.
The contest is conducted in several head-to-head rounds, each between two cows. If cow has a greater skill level than cow , then cow will always beat cow .
Farmer John is trying to rank the cows by skill level. Given a list the results of two-cow rounds, determine the number of cows whose ranks can be precisely determined from the results. It is guaranteed that the results of the rounds will not be contradictory.
Input
The first line contains two integers and . Each of the next lines contains two integers that describe the competitors and results (the first integer , is the winner) of a single round of competition: and .
Output
Print a single integer representing the number of cows whose ranks can be determined.