P2419 [USACO08JAN] Cow Contest S
Description
$ N (1 ≤ N ≤ 100) $ cows, conveniently numbered $ 1 ~ N $ , are participating 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 $ A $ has a greater skill level than cow $ B (1 ≤ A ≤ N; 1 ≤ B ≤ N; A ≠ B) $, then cow $ A $ will always beat cow $ B $ .
Farmer John is trying to rank the cows by skill level. Given a list the results of $ M (1 ≤ M ≤ 4,500) $ 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 Format
第一行两个用空格隔开的整数 $N, M$。
第 $2\sim M + 1$ 行,每行为两个用空格隔开的整数 $A, B$ ,描述了参加某一轮比赛的奶牛的编号,以及结果(每行的第一个数的奶牛为**胜者**)。
Output Format
输出一行一个整数,表示排名可以确定的奶牛的数目。
Explanation/Hint
样例解释:
编号为 $2$ 的奶牛输给了编号为 $1, 3, 4$ 的奶牛,也就是说她的水平比这 $3$ 头奶牛都差。而编号为 $5$ 的奶牛又输在了她的手下,也就是说,她的水平比编号为 $5$ 的奶牛强一些。于是,编号为 $2$ 的奶牛的排名必然为第 $4$,编号为 $5$ 的奶牛的水平必然最差。其他 $3$ 头奶牛的排名仍无法确定。