{-# LANGUAGE TypeApplications, TupleSections #-}

import Control.Monad
import Data.List

main = do
    xs <- fmap (, 1) <$> ((readLn @ Int) >>= (flip replicateM) getLine)
    ys <- fmap (, -1) <$> ((readLn @ Int) >>= (flip replicateM) getLine)

    print $ (foldl max 0 . fmap (sum . fmap snd) . groupBy ((. fst) . (==) . fst) . sort) (xs ++ ys)
