let n, m = Scanf.scanf " %d %d" @@ fun a b -> a, b
let a_ss = Array.(init n @@ fun _ -> Scanf.(scanf " %d" @@ fun k -> init k @@ fun _ -> scanf " %d" pred))
let cs = Array.make m 0
let _ = Array.(iter (fun a_s -> iter (fun a -> cs.(a) <- cs.(a) + 1) a_s) a_ss; fold_left (fun a c -> a + if c = n then 1 else 0) 0 cs) |> Printf.printf "%d\n"