fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map{it.toInt()}
    val x = Array(M) {0}
    val y = Array(M) {0}

    for (i in x.indices) {
        val (X, Y) = readLine()!!.split(" ").map{it.toInt() - 1}

        x[i] = X
        y[i] = Y
    }

    val f = Array(N) { false }
    val cnt = Array(N) { 1 }
    f[0] = true

    for (i in x.indices) {
        cnt[x[i]]--
        cnt[y[i]]++
        f[y[i]] = f[y[i]] || f[x[i]]

        if (cnt[x[i]] == 0) {
            f[x[i]] = false
        }
    }

    println(f.count {it})
}
