(* O(k^2) (k = max n m) *)
Scanf.scanf " %d" @@ fun n ->
  let ss = Array.init n @@ fun _ -> Scanf.scanf " %s" @@ fun s -> s in
  let m = Scanf.scanf " %d" @@ (+) 0 in
  let ts = Array.init m @@ fun _ -> Scanf.scanf " %s" @@ fun t -> t in
  let f acc s =
    let c = Array.fold_left (fun c s' -> if s' = s then c + 1 else c) 0 ss in
    let c = Array.fold_left (fun c t -> if t = s then c - 1 else c) c ts in
    max acc c in
  Array.to_list ss |> List.sort_uniq compare |> List.fold_left f 0
  |> Printf.printf "%d\n"