Description the desire of every cow is to become one of the most popular cows. Now there are n cows, give you m-pairs of integers (a, a, b), indicating that cow A is considered to be popular. This relationship is transitive, and if a thinks B is popular, B thinks C is popular, then bull a also thinks that Ox C is popular. Your task is to find out how many cows are considered popular by all cows. Input first row two number n,m. Next m line, two numbers per line, A, B, meaning that A is considered a welcome (the information given may be repeated, that is, there may be multiple, b) Output
A number, that is, how many cows are considered popular by all cows.
Sample Input3 3
1 2
2 1
2 3Sample Output1HINT100% data n<=10000,m<=50000 positive solution: Tarjan Problem Solving report: With POJ on the same topic, previously wrote the problem, Portal:http://www.cnblogs.com/ljh2000-jump/p/5628445.html
BZOJ1051 [HAOI2006] Popular Cattle