let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let xys = Array.init m @@ fun _ -> Scanf.scanf " %d %d" @@ fun a b -> a - 1, b - 1
let rs, bs = Array.(make n false, make n 1)
let _ = rs.(0) <- true; Array.(iteri (fun i (x, y) -> rs.(y) <- rs.(y) || rs.(x); bs.(x) <- bs.(x) - 1; if bs.(x) = 0 then rs.(x) <- false; bs.
(y) <- bs.(y) + 1) xys; Printf.printf "%d\n" @@ fold_left (fun c b -> c + if b then 1 else 0) 0 rs)