import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val m = sc.nextInt()
  val xy = (1..m).map { Pair(sc.nextInt(), sc.nextInt()) }

  val array = Array(n) { 1 }
  val reds = Array(n) { false }
  reds[0] = true

  for (xyi in xy) {
    val x = xyi.first - 1
    val y = xyi.second - 1

    if (array[x] == 0) {

    } else if (array[x] == 1) {
      array[x] = array[x] - 1
      array[y] = array[y] + 1
      if (reds[x]) {
        reds[y] = true
      }

      reds[x] = false
    } else {
      array[x] = array[x] - 1
      array[y] = array[y] + 1
      if (reds[x]) {
        reds[y] = true
      }
    }
  }

  // println(array.joinToString(" "))

  println(reds.filter { it }.size)

}
