import Data.List

fold_blue::[String]->[(String,Int)]
fold_blue = (map (\ ls -> (head ls,length ls) )).group.sort

check_red::[(String,Int)]->[String]->[(String,Int)]
check_red dat []      =dat
check_red dat (s:rest)= check_red (modify s dat) rest

modify::String->[(String,Int)]->[(String,Int)]
modify s [] = []
modify s ((t,v):rest) = if s == t then ((t,v-1):rest) else (t,v):(modify s rest)

solver::[String]->[String]->Int
solver blue_dat red_dat = let ls = ("",0):check_red (fold_blue blue_dat) red_dat in
                          maximum (map snd ls)

n_get::Int->IO [String]
n_get 0 = return []
n_get n = do
  d<-getLine
  rest<-n_get (n-1)
  return (d:rest)

main::IO()
main=do
  nc<-getLine
  let n=read nc
  blue<-n_get n
  mc<-getLine
  let m=read mc
  red<-n_get m
  print (solver blue red)