[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let [N;M] = reads int
    let XYS = List.init M (fun _ -> reads int)

    let b = Array.create (N + 1) 1
    let r = Array.create (N + 1) false
    r.[1] <- true

    for [f;t] in XYS do
        b.[f] <- b.[f] - 1
        b.[t] <- b.[t] + 1
        if r.[f] then r.[t] <- true
        if b.[f] = 0 then r.[f] <- false

    Array.filter ((=) true) r
    |> Array.length
    |> printfn "%i"

    0