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


void main() {
    int n, m;
    scan(n, m);
    auto cnt = new int[](n);
    auto red = new bool[](n);
    cnt[] = 1;
    red[0] = 1;

    foreach (i ; 0 .. m) {
        int xi, yi;
        scan(xi, yi);
        xi--, yi--;
        if (red[xi]) {
            red[yi] = 1;
            if (cnt[xi] - 1 == 0) red[xi] = 0;
        }
        cnt[xi]--;
        cnt[yi]++;
    }

    auto ans = iota(n).count!(i => red[i] && cnt[i] > 0);
    writeln(ans);
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
