output_description: Print the number of boxes that may contain the red ball after all operations
  are performed.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N M
      x_1 y_1
      :
      x_M y_M
attempt: # https://atcoder.jp/contests/agc002/tasks/agc002_b
  import sys
  
  sys.setrecursionlimit(1 << 25)
  read = sys.stdin.readline
  ra = range
  enu = enumerate
  
  
  def mina(*argv, sub=1):
      return list(map(lambda x: x - sub, argv))
  
  
  # 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと
  
  
  def read_a_int():
      return int(read())
  
  
  def read_ints():
      return list(map(int, read().split()))
  
  
  def read_col(H):
      """H is number of rows
      A列、B列が与えられるようなとき
      ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合"""
      ret = []
      for _ in range(H):
          ret.append(list(map(int, read().split())))
      return tuple(map(list, zip(*ret)))
  
  
  N, M = read_ints()
  X, Y = read_col(M)
  X = mina(*X)
  Y = mina(*Y)
  # 有向グラフでつないで1からbfsで到達するノードの数を記録する？#順序情報が消えてしまう
  # ただ単純に赤の可能性のある配列を用意しておけばいいんじゃない？
  # ボールの個数も管理しないと
  prob = [False] * N
  n_balls = [1] * N
  prob[0] = True
  
  for x, y in zip(X, Y):
      prob[y] = prob[y] or prob[x]
      n_balls[x] -= 1
      n_balls[y] += 1
      if n_balls[x] == 0:
          prob[x] = False
  
  
  print(sum(prob))
  
problem_description: Statement
  
  We have N boxes, numbered 1 through N. At first, box 1 contains one red ball,
  and each of the other boxes contains one white ball.
  
  Snuke will perform the following M operations, one by one. In the i-th
  operation, he randomly picks one ball from box x_i, then he puts it into box
  y_i.
  
  Find the number of boxes that may contain the red ball after all operations
  are performed.
samples: [{"input": "3 2\n    1 2\n    2 3", "output": "2\n    \n\nJust after the first operation, box 1 is empty, box 2 contains one red ball\nand one white ball, and box 3 contains one white ball.\n\nNow, consider the second operation. If Snuke picks the red ball from box 2,\nthe red ball will go into box 3. If he picks the white ball instead, the red\nball will stay in box 2. Thus, the number of boxes that may contain the red\nball after all operations, is 2.\n\n* * *"}, {"input": "3 3\n    1 2\n    2 3\n    2 3", "output": "1\n    \n\nAll balls will go into box 3.\n\n* * *"}, {"input": "4 4\n    1 2\n    2 3\n    4 1\n    3 4", "output": "3"}]