void main()
{
    long[] tmp = readln.split.to!(long[]);
    long n = tmp[0], m = tmp[1];

    bool[] boxes = new bool[n];
    boxes[0] = true;
    long[] balls = new long[n];
    balls[] = 1;
    foreach (i; 0 .. m)
    {
        tmp = readln.split.to!(long[]);
        long x = tmp[0] - 1, y = tmp[1] - 1;
        --balls[x], ++balls[y];
        if (boxes[x]) boxes[y] = true;
        if (balls[x] < 1) boxes[x] = false;
    }

    boxes.count(true).writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;