let () =
  let n, m = Scanf.scanf "%d %d\n" (fun n m -> n, m) in
  let xys = Array.init m (fun _ -> Scanf.scanf "%d %d\n" (fun x y -> x - 1, y - 1)) in
  let balls = Array.make n 1 in
  let possible = Array.init n (function 0 -> true | _ -> false) in
  Array.iter (fun (x, y) ->
    balls.(x) <- balls.(x) - 1;
    balls.(y) <- balls.(y) + 1;
    possible.(y) <- possible.(y) || possible.(x);
    possible.(x) <- possible.(x) && balls.(x) <> 0) xys;
  Printf.printf "%d\n" (List.length (List.filter (fun b -> b) (Array.to_list possible)))
