#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=105;
int n,m;
int f[N][N];
int dp[N][N];
int t;
signed main(){
cin>>n>>m;
for(int i=1;i<=m;i++){
int x,y;
cin>>x>>y;
f[x][y]=1;
dp[y][x]=1;
}
for(int k=1;k<=n;k++){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(f[i][k]&&f[k][j])f[i][j]=1;
if(dp[i][k]&&dp[k][j])dp[i][j]=1;
}
}
}
for(int i=1;i<=n;i++){
int ans=0,cnt=0;
for(int j=1;j<=n;j++){
if(f[i][j])ans++;
if(dp[i][j])cnt++;
}
if(ans>n/2||cnt>n/2)t++;
}
cout<<t;
return 0;
}