#P2419. Cow Ranking Determination
Cow Ranking Determination
Cow Ranking Determination
Farmer John's \(N\) cows participated in a programming contest. Each cow has a unique constant skill rating. The contest is held in several head-to-head rounds where, in each round, if cow \(A\) has a higher skill rating than cow \(B\) then cow \(A\) always wins. Given \(M\) rounds of competition results, determine the number of cows whose rankings can be precisely determined.
A cow's ranking can be exactly determined if, through direct or indirect results, her skill can be compared with every other cow. The rounds' results are guaranteed to be consistent, with no contradictory outcomes.
inputFormat
The first line contains two integers \(N\) and \(M\), where \(1 \leq N \leq 100\) and \(1 \leq M \leq 4500\).
Each of the next \(M\) lines contains two integers \(A\) and \(B\) (with \(A \neq B\)), indicating that cow \(A\) beat cow \(B\).
outputFormat
Output a single integer, the number of cows whose ranking can be precisely determined based on the contest results.
sample
5 5
4 3
4 2
3 2
1 2
2 5
2
</p>