#include<iostream>
#include<cstdio>
#include<cstring>
#define inf 999999999
using namespace std;
int n,m;
int stan;
int out=0;
int dis[1005][1005];
int road[1005][1005];
int count[10005];
int temp[10005];
void floyd()
{
for(int k=1;k<=n;k++)
{
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(dis[i][j]>(dis[i][k]+road[k][j]))
{
dis[i][j]=dis[i][k]+road[k][j];
}
}
}
}
}
int main()
{
scanf("%d%d",&n,&m);
memset(count,0,sizeof(count));
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(i==j)
continue;
road[i][j]=inf;
dis[i][j]=inf;
}
}
stan=(n+1)/2;
for(int i=1;i<=m;i++)
{
int x,y;
scanf("%d%d",&x,&y);
road[x][y]=1;
dis[x][y]=1;
}
floyd();
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(i==j)
continue;
if(dis[i][j]!=inf)
{
count[j]++;
temp[i]++;
}
}
}
for(int i=1;i<=n;i++)
if(count[i]>=stan||temp[i]>=stan) out++;
cout<<out;
return 0;
}