import Control.Monad
import Data.List

main = do
    n <- readLn
    s <- replicateM n getLine
    m <- readLn
    t <- replicateM m getLine
    putStrLn . show $ resolve s t

resolve:: [String] -> [String] -> Int
resolve s t = max 0 (maximum (piyo s t))

hoge:: Int -> [String] -> String -> Int
hoge n [] a = n
hoge n (t:ts) a
    | t == a = hoge (n + 1) ts a
    | otherwise = hoge n ts a

fuga:: [String] -> [String] -> [Int]
fuga s t = map (hoge 0 s) t

piyo s t = map (\x -> (fst x) - (snd x)) $ zip (fuga s s) (fuga t s)
