import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, m;
    scan(n, m);

    auto cnt = new int[](n);
    cnt[] = 1;
    auto canRed = new bool[](n);
    canRed[0] = 1;

    foreach (i ; 0 .. m) {
        int xi, yi;
        scan(xi, yi);
        xi--, yi--;

        if (canRed[xi]) {
            canRed[yi] = true;
        }

        cnt[xi]--;
        cnt[yi]++;

        if (cnt[xi] == 0) {
            canRed[xi] = false;
        }

        debug {
            writefln("cnt: %(%s %)", cnt);
            writefln("red: %(%b %)", canRed);
        }
    }

    int ans = canRed.count!"a".to!int;

    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);
        }
    }
}
