#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 NN cows, and you are given MM pairs of integers (A,B)(A,B), indicating that cow AA considers cow BB popular. This relationship is transitive—if cow AA considers cow BB popular, and cow BB considers cow CC popular, then cow AA also considers cow CC 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, NN and MM;
The next MM lines each contain two numbers, AA and BB, meaning cow AA considers cow BB popular (the given information may contain duplicates, meaning multiple occurrences of the same A,BA,B 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, 1N104,1M5×1041\le N\le 10^4,1\le M\le 5\times 10^4.