#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,ans1,ans2,sum;
int head1[600],head2[600],vis[600];
struct node
{
int next;
int to;
}road1[6000],road2[6000];
void dfs1(int now)
{
vis[now]=1;
for(int i=head1[now];i;i=road1[i].next)
{
if(!vis[road1[i].to])
{
ans1++;
dfs1(road1[i].to);
}
}
}
void dfs2(int now)
{
vis[now]=1;
for(int i=head2[now];i;i=road2[i].next)
{
if(!vis[road2[i].to])
{
ans2++;
dfs2(road2[i].to);
}
}
}
int main()
{
cin>>n>>m;
//node road1[6000],road2[6000];
int sum1[6000]={0},sum2[6000]={0};
int k1=0,k2=0;
for(int i=1;i<=m;i++)
{
int x,y;
cin>>x>>y;
road1[++k1].to=y;
road1[k1].next=head1[x];
head1[x]=k1;
road2[++k2].to=x;
road2[k2].next=head2[y];
head2[y]=k2;
}
for(int i=1;i<=n;i++)
{
ans1=0;
memset(vis,0,sizeof(vis));
dfs1(i);
if(ans1>=(n+1)/2)sum++;
}
for(int i=1;i<=n;i++)
{
ans2=0;
memset(vis,0,sizeof(vis));
dfs2(i);
if(ans2>=(n+1)/2)sum++;
}
cout<<sum;
return 0;
}