import std.algorithm;
import std.stdio;

void main ()
{
	int n, m;
	while (readf (" %s %s", &n, &m) > 0)
	{
		auto b = new bool [n];
		b[0] = true;
		auto c = new int [n];
		c[] = 1;
		foreach (j; 0..m)
		{
			int u, v;
			readf (" %s %s", &u, &v);
			u--;
			v--;
			if (b[u])
			{
				b[v] = true;
			}
			c[u]--;
			c[v]++;
			if (c[u] == 0)
			{
				b[u] = false;
			}
		}
		writeln (sum (b));
	}
}
