#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)

using namespace std;

const int N=1e5+100;
int n,m,cnt[N],a[N],ans;

int main(){
	scanf("%d%d",&n,&m);
	a[1]=1;
	rep (i,1,n) cnt[i]=1;
	rep (i,1,m){
		int x,y; scanf("%d%d",&x,&y);
		a[y]|=a[x]; cnt[y]++,cnt[x]--;
		if (!cnt[x]) a[x]=0;
	}
	rep (i,1,n) ans+=a[i];
	printf("%d\n",ans);
	return 0;
}