#include <cstdio>

#define N 100000

int n, m, x, y, a[N + 9];
bool u[N + 9];

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) a[i] = 1;
	u[1] = true;
	while (m--) {
		scanf("%d%d", &x, &y);
		u[y] |= u[x];
		if (!--a[x]) u[x] = false;
		++a[y];
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) ans += u[i];
	printf("%d\n", ans);
	return 0;
}
