Scanf.(Array.(scanf " %d %d" @@ fun n m ->
  let a = make m 0 in
  init n (fun _ -> scanf " %d" @@ fun v ->
    init v (fun _ -> scanf " %d" @@ fun w ->
      a.(w-1) <- a.(w-1) + 1));
  print_int @@ fold_left (fun sum v -> if v=n then sum+1 else sum) 0 a))