fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val count = IntArray(n) { 1 }
    val may = BooleanArray(n)
    may[0] = true
    for (i in 1..m) {
        val (x, y) = readLine()!!.split(' ').map { x -> x.toInt() - 1 }
        may[y] = may[y] || may[x]
        count[x]--; count[y]++
        if (count[x] == 0) may[x] = false
    }
    println(may.count { it })
}
