import Data.List

main = do
        xs <- f <$> (getLine *> getLine)
        ys <- f <$> (getLine *> getLine)
        print.length $ xs `intersect` ys
    where f = nub.map (read :: String -> Int).words