import Data.Graph import Data.Array.Unboxed main = interact $ show . def def = solve . map(map(read :: String -> Int) . words) . lines solve ([n, _] : ab) = length $ filter(==0) $ elems $ indegree $ buildG(1, n) $ map(\[a, b] -> (a, b)) ab