#include<iostream>
#include<cstring>
using namespace std;
const int maxn = 505;
int n,m,Map[maxn][maxn],vis[maxn];
int min_dfs(int x){
vis[x]=1;
int ans=1;
for(int i=1;i<=n;i++){
if(Map[x][i]==1&&!vis[i]){
ans+=min_dfs(i);
}
}
return ans;
}
int max_dfs(int x){
vis[x]=1;
int ans=1;
for(int i=1;i<=n;i++){
if(Map[x][i]==2&&!vis[i]){
ans+=max_dfs(i);
}
}
return ans;
}
int main(){
cin>>n>>m;
int h=(n+1)>>1;
while(m--){
int x,y;
cin>>x>>y;
Map[x][y]=1; //x->y
Map[y][x]=2; //y->x
}
int cnt=0;
for(int i=1;i<=n;i++){
int mins=min_dfs(i);
memset(vis,0,sizeof(vis));
int maxs=max_dfs(i);
memset(vis,0,sizeof(vis));
// if(mins>=1&&mins<=h&&maxs>=0&&maxs<=h){
// continue;
// }else
if(mins>h||maxs>h){
cnt++;
}
}
cout<<cnt<<endl;
return 0;
}