#Q93. 「一本通 3.5 例 1」受欢迎的牛
「一本通 3.5 例 1」受欢迎的牛
Description
Original Source: USACO 2003 Fall
Every cow's dream is to become the most popular cow. Now there are cows, and you are given pairs of integers , indicating that cow considers cow popular. This relationship is transitive—if cow considers cow popular, and cow considers cow popular, then cow also considers cow popular. Your task is to determine how many cows are considered popular by every other cow except themselves.
Input Format
The first line contains two numbers, and ;
The next lines each contain two numbers, and , meaning cow considers cow popular (the given information may contain duplicates, meaning multiple occurrences of the same pair are possible).
Output Format
Output the number of cows that are considered popular by every other cow except themselves.
Sample 1
Only the third cow is considered popular by every other cow except itself.
3 3
1 2
2 1
2 3
1
Data Range and Hints
For all data, .