#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> boxsum(n,1);
	vector<int> boxred(n,0);
	boxred[0]=1;
	int m;
	cin>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		x--,y--;
		boxsum[y]++;
		if(boxred[x]==1) boxred[y]=1;
		boxsum[x]--;
		if(boxsum[x]==0) boxred[x]=0;

	}
	int res=accumulate(boxred.begin(),boxred.end(),0);
	cout<<res<<endl;

	
	
	return 0;
}
