#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int n, m; cin >> n >> m;
	bool b[114514];
	int a[114514];
	for (int i = 1; i <= n; i++) {
		b[i] = (i == 1);
		a[i] = 1;
	}
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		if (b[x])b[y] = true;
		a[x]--; a[y]++;
		if (!a[x])b[x] = false;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) 
		ans += b[i];
	cout << ans << endl;
}