fun main(arg: Array<String>) {
    val (N, M) = listOfInt()
    val red = Array<Boolean>(N) {false}
    val box = Array<Int>(N) {1}
    red[0] = true
    for (m in 1 .. M) {
        val (x, y) = listOfInt(-1)
        if (red[x]) red[y] = true 
        box[y] += 1; box[x] -= 1
        if (box[x] == 0) red[x] = false 
    }
    println(red.count {it})
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }