#include<iostream>
#include<cstdio>
#include<cstring>
const int N=100100;
bool ex[N];
int cnt[N];
int n,m,ans;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)cnt[i]=1;
	ex[1]=1;
	for(int x,y;m--;)
	{
		scanf("%d%d",&x,&y);
		cnt[x]--;cnt[y]++;
		if(ex[x])ex[y]=1;
		if(!cnt[x])ex[x]=0;
	}
	for(int i=1;i<=n;i++)
		ans+=ex[i];
	printf("%d\n",ans);
	return 0;
}
