#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	bool red[n];
	int boll[n];
	rep(i,n){
		red[i]=i?false:true;
		boll[i]=1;
	}
	int x,y;
	rep(i,m){
		cin>>x>>y;
		x--;y--;
		boll[x]--;boll[y]++;
		if(red[x]>0)red[y]=true;
		if(boll[x]==0)red[x]=false;
	}
	int ans=0;
	rep(i,n)ans+=red[i]?1:0;
	cout<<ans<<endl;
	return 0;
}