#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100000
int n,Q;
int u,v,ans;
int cnt[MAXN+5],red[MAXN+5];
int main()
{
	scanf("%d%d",&n,&Q);
	red[1]=1;
	while(Q--)
	{
		scanf("%d%d",&u,&v);
		if(red[u])
		{
			if(!cnt[u])red[u]=0;
			red[v]=1;
		}
		cnt[u]--,cnt[v]++;
	}
	for(int i=1;i<=n;i++)if(red[i])ans++;
	printf("%d",ans);
}