object Main extends App {

  import scala.io.StdIn.readLine
  val Array(n, m) = readLine().trim.split(" ").map(_.toInt)
  val arr = Array.fill(n)((1, 0))
  arr(0) = (0, 1)
  (0 until m).foreach { i =>
    val Array(a, b) = readLine().trim.split(" ").map(_.toInt)
    val x = a - 1
    val y = b - 1
    if (0  < arr(x)._2) {
      arr(y) = (0, arr(y)._1 + arr(y)._2 + 1)
      arr(x) = (arr(x)._1, arr(x)._2 - 1)
    } else {
      if (0 < arr(y)._2) {
        arr(y) = (0, arr(y)._1 + arr(y)._2 + 1)
        arr(x) = (arr(x)._1 - 1, arr(x)._2)
      } else {
        arr(y) = (arr(y)._1 + 1, arr(y)._2)
        arr(x) = (arr(x)._1 - 1, arr(x)._2)
      }
    }
  }

  println(arr.count(t => t._2 > 0))

}
