{-# OPTIONS_GHC -Wall #-}

import qualified Data.IntSet as S

readInt :: String -> Int
readInt = read

solve :: [Int] -> [Int] -> Int
solve xs ys = S.size $ S.intersection xs' ys'
    where
        xs' = S.fromList xs
        ys' = S.fromList ys

main :: IO ()
main = do
    _  <- getLine
    xs <- fmap (map readInt . words) getLine
    _  <- getLine
    ys <- fmap (map readInt . words) getLine

    let ans = solve xs ys

    print $ ans

