#P2341. Star Cow
Star Cow
Star Cow
Problem Statement:
Every cow dreams of being a star in the barn. A cow is considered a star if it is liked (directly or indirectly) by every other cow. Note that every cow always likes itself, and the liking relation is transitive; that is, if \(A\) likes \(B\) and \(B\) likes \(C\), then \(A\) also likes \(C\).
Given \(N\) cows and \(M\) liking relationships, determine how many cows can become stars.
inputFormat
Input Format:
The first line contains two integers \(N\) and \(M\), representing the number of cows and the number of liking relationships, respectively.
The next \(M\) lines each contain two integers \(u\) and \(v\), indicating that cow \(u\) likes cow \(v\>.
outputFormat
Output Format:
Output a single integer representing the number of cows that can be stars.
sample
3 3
1 2
2 3
3 1
3