#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	vector<bool> f(N+10, 0);
	vector<int> a(N+10, 1);
	f[1] = 1;
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		f[y] = f[x] || f[y];
		a[y]++, a[x]--;
		if (!a[x]) f[x] = 0;
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (f[i]) ans++;
	}
	cout << ans << endl;
}