#include<bits/stdc++.h>
using namespace std;
int n,m,z[100010],b[100010];
int main()
{
    cin>>n>>m;
    b[1]=1;
    for(int i=1;i<=n;++i)z[i]=1;
    for(int i=1;i<=m;++i){
        int x,y;
        scanf("%d%d",&x,&y);
        b[y]|=b[x];
        z[x]--;z[y]++;
        if (z[x]==0)b[x]=0;
	}
	int ans=0;
	for(int i=1;i<=n;++i){
	    if(b[i]&&z[i])ans++;
	}
	cout<<ans<<endl;
}