import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    long n, m;
    scan(n, m);
    auto 色 = new bool[](n);
    色[0] = true;
    auto 個数 = new long[](n);
    個数[] = 1;
    foreach (i; 0 .. m)
    {
        long x, y;
        scan(x, y);
        // writeln(x, y);
        個数[x - 1] -= 1;
        個数[y - 1] += 1;
        if (色[x - 1])
        {
            色[y - 1] = true;
        }
        if (個数[x - 1] == 0)
        {
            色[x - 1] = false;
        }
    }
    // writeln(個数);
    // writeln(色);
    long cnt;
    foreach (i; 0 .. n)
    {
        if (色[i] == true && 個数[i] >= 0)
        {
            cnt += 1;
        }
    }
    writeln(cnt);
}

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

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}
