import Data.List(group, sort, nub)
import Control.Monad(replicateM)

main = do
  n <- readLn :: IO Int
  bs <- replicateM n getLine
  m <- readLn :: IO Int
  rs <- replicateM m getLine
  putStrLn $ show $ solve bs rs 

solve :: [String] -> [String] -> Int
solve bs rs = maximum $ map fu words
  where
    fu = calc (labeled bs) (labeled rs)
    words = nub (bs ++ rs)

labeled :: [String] -> [(String, Int)]
labeled ls = zipWith (\a b -> ((head a), length b)) sorted sorted
  where
    sorted = group $ sort ls

choose :: String -> [(String, Int)] -> (String, Int)
choose w [] = (w,0)
choose w ys
  | w ==  fst h = h
  | otherwise = choose w (tail ys)
  where
    h = head ys

calc :: [(String, Int)] -> [(String, Int)] -> String -> Int
calc bs rs w = subtract (snd r) (snd b)
  where
    b = choose w bs
    r = choose w rs