fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { m -> m.toInt() }
    
    val balls = Array(n) { 1 }
    val isRed = Array(n) { false }
    isRed[0] = true
    
    for (i in 0 until m) {
        val (a, b) = readLine()!!.split(" ").map { m -> m.toInt() }
        balls[a - 1]--
        balls[b - 1]++
        if (isRed[a - 1]) {
            isRed[b - 1] = true
        }
        if (balls[a - 1] == 0) {
            isRed[a - 1] = false
        }
    }
    
    println(isRed.filter { m -> m }.size)
}
