import           Control.Applicative
import           Control.Monad
import           Control.Monad.State

deleteFirst :: Eq a => a -> [a] -> [a]
deleteFirst _ [] = []
deleteFirst a (t : ts) | a == t    = ts
                       | otherwise = t : deleteFirst a ts

main = do
  n <- readLn
  s <- take n . map (read :: String -> Int) . words <$> getLine
  q <- readLn
  t <- take q . map (read :: String -> Int) . words <$> getLine
  let res = foldl (\acc o -> deleteFirst o acc) s t
  print $ (length s) - (length res)

