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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int N, M;
	cin >> N >> M;
	
	vector< int > red(N, 0), cnt(N, 1);
	red[0] = 1;
	
	for_(i,0,M) {
		int x, y;
		cin >> x >> y;
		--x; --y;
		
		--cnt[x];
		++cnt[y];
		
		if (red[x]) {
			red[y] = 1;
			if (cnt[x] == 0) red[x] = 0;
		}
	}
	
	int ans = 0;
	for_(i,0,N) if (red[i] && cnt[i] > 0) ++ans;
	cout << ans << endl;
}