import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  n <- read <$> getLine :: IO Int
  ss <- replicateM n getLine
  m <- read <$> getLine :: IO Int
  ts <- replicateM m getLine
  putStrLn $ show $ solve ss ts

solve ss ts = maximum $ 0 : (map reduction $ group' ss)
  where
    reduction (s, n) = n - (length . filter (== s)) ts

group' :: [String] -> [(String, Int)]
group' [] = []
group' (s:ss) = (s, 1 + (length . filter (== s)) ss) : (group' . filter (/= s)) ss
