import std;

auto input()
{
    return readln().chomp();
}

alias sread = () => readln.chomp();

void main()
{
    long n, m;
    scan(n, m);
    //writeln(n, m);
    auto color = new bool[](n);
    color[0] = true;
    auto cup = new long[](n);
    cup[] = 1;
    foreach (i; 0 .. m)
    {
        long x, y;
        scan(x, y);
        //writeln(x, y);
        cup[x - 1] -= 1;
        cup[y - 1] += 1;
        if (color[x - 1])
        {
            color[y - 1] = true;
        }
        if (cup[x - 1] == 0)
        {
            color[x - 1] = false;
        }
    }
    // writeln(cup);
    // writeln(color);
    auto cnt = 0L;
    foreach (i; 0 .. n)
    {
        if (cup[i] != 0 && color[i])
        {
            cnt += 1;

        }
    }
    writeln(cnt);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;

    }
}
