let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let a = Array.init n (fun _ ->
    Scanf.scanf " %d" @@ fun k ->
    Array.init k (fun _ -> Scanf.scanf " %d" ((+) 0)))
  in
  Array.init m (fun i ->
    let i = i+1 in
    let c = Array.fold_left (
      Array.fold_left (fun s v ->
        if v = i then s+1 else s)) 0 a
    in if c = n then 1 else 0)
  |> Array.fold_left (+) 0
  |> Printf.printf "%d\n"
