Scanf.scanf "%d %d" @@ fun n m ->
  let c = Array.init (n+1) (fun i -> 1) in
  let r = Array.make (n+1) false in
  r.(1) <- true;
  for _ = 1 to m do
    Scanf.scanf " %d %d" @@ fun x y ->
    if r.(x) then r.(y) <- true;
    if c.(x) = 1 then r.(x) <- false;
    c.(x) <- c.(x) - 1;
    c.(y) <- c.(y) + 1;
  done;
  Array.fold_left (fun s x -> if x then s+1 else s) 0 r
  |> Printf.printf "%d\n"