#Lutece0260. Popular Cows
Popular Cows
Migrated from Lutece 260 Popular Cows
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Every cow's dream is to become the most popular cow in the herd. In a herd of cows, you are given up to ordered pairs of the form that tell you that cow thinks that cow is popular. Since popularity is transitive, if thinks is popular and thinks is popular, then will also think that is popular, even if this is not explicitly specified by an ordered pair in the input. Your task is to compute the number of cows that are considered popular by every other cow.
Input
-
Line : Two space-separated integers, and
-
Lines : Two space-separated numbers and , meaning that thinks is popular.
Process to end of file.
Output
For each case:
Output A single integer on a single line that is the number of cows who are considered popular by every other cow.
Samples
3 3
1 2
2 1
2 3
1
Note
Cow is the only cow of high popularity.
Resources
USACO 2003 Fall