import std.stdio, std.string, std.conv;
import std.algorithm, std.array, std.range;

void main()
{
    for(string s_; (s_=readln().chomp()).length;)
    {
        auto NM = s_.split().map!(to!int)();
        immutable N=NM[0], M=NM[1];
        auto xy = new int[][M];
        foreach(ref a;xy) a=readln.split.map!(x=>x.to!int()-1).array();
        auto c = new int[N]; c[]=1;
        auto p = new bool[N]; p[]=false; p[0]=true;
        foreach(ref a;xy)
        {
            immutable x=a[0], y=a[1];
            ++c[y]; p[y]=p[y]||p[x];
            --c[x]; p[x]=p[x]&&c[x]!=0;
        }
        writeln(count(p,true));
    }
}