
fun main(args: Array<String>){
    
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val xy = Array(m) {
        readLine()!!.split(" ").map { it.toInt() }
    }

    var box = Array(n) { 1 }
    var red = Array(n) { false }
    red[0] = true
    
    for ( (x,y) in xy ){
        
        box[x-1] -= 1
        box[y-1] += 1

        if ( red[x-1] == true ) { red[y-1] = true }
        if ( box[x-1] == 0 ) { red[x-1] = false }
    }

    var ans = 0
    for (r in red) { if ( r == true ) { ans++ } }
    println(ans)
}