1 #include <iostream>
2 #include <algorithm>
3 #include <string>
4 #include <cstring>
5 using namespace std;
6
7 int n, m;
8 const int maxn = 105;
9 int mp[maxn][maxn];
10
11 int main(){
12 ios_base::sync_with_stdio(false);
13 cin.tie(0);
14 memset(mp, 0, sizeof(mp));
15 cin >> n >> m;
16 for(int i = 0;i < m;i++){
17 int x, y;
18 cin >> x >> y;
19 mp[x][y] = 1;
20 mp[y][x] = -1;
21 }
22
23 for(int i = 1;i <= n;i++){
24 for(int j = 1;j <= n;j++){
25 for(int k = 1;k <= n;k++){
26 if(mp[j][i] == mp[i][k] && mp[j][i] != 0){
27 mp[j][k] = mp[j][i];
28 }
29 }
30 }
31 }
32 int ans = 0;
33 for(int i = 1;i <= n;i++){
34 int sum = 0;
35 for(int j = 1;j <= n;j++){
36 if(mp[i][j] != 0){
37 sum++;
38 }
39 }
40 if(sum == n-1){
41 ans++;
42 }
43 }
44 cout << ans << endl;
45
46 return 0;
47 }
floyed