import           Control.Applicative
import           Control.Monad

binarySearch :: Int -> [Int] -> Bool
binarySearch x ys = go x ys
  where
    go s ts =
        case splitAt (length ts `div` 2) ts of
            ([], [b]) -> b == s
            ([a], [b]) -> a == s || b == s
            (as, (b:bs))
                | s < b -> go s as
                | s > b -> go s bs
                | otherwise -> True

main :: IO ()
main = do
    getLine
    ss <- fmap read . words <$> getLine :: IO [Int]
    getLine
    ts <- fmap read . words <$> getLine :: IO [Int]
    print . length $ filter (\t -> binarySearch t ss) ts

