import Control.Applicative ((<$>))
import Control.Monad (replicateM)
import Data.List

main :: IO ()
main = do
  n <- readLn
  ss <- replicateM n getLine
  m <- readLn
  ts <- replicateM m getLine
  print $ solve ss ts

solve :: [String] -> [String] -> Int
solve ss ts = let ds = ss \\ ts
              in f . map length . group . sort $ ds
  where
    f xs | null xs = 0
         | otherwise = maximum xs
