{-# OPTIONS_GHC -O #-}

import Control.Monad
import Data.List
import qualified Data.Map.Strict as M

main = do
    n <- readLn :: IO Int
    bs <- foldl' (\ma k -> M.insertWith(+)k 1 ma) M.empty <$> replicateM n getLine :: IO(M.Map String Int)
    m <- readLn :: IO Int
    rs <- foldl' (\ma k -> M.insertWith(+)k 1 ma) M.empty <$> replicateM m getLine :: IO(M.Map String Int)
    --
    print.last .sort.(:) 0.map snd.M.toList$ M.mapWithKey (f rs) bs
    --
    return ()
    --
    where f rs k a = case M.lookup k rs of
                        Just n -> a-n
                        Nothing -> a
