import Data.List (foldl')
import Data.Vector.Unboxed (Vector, fromList, (!), null)
import qualified Data.Vector.Unboxed as V
import Debug.Trace (trace)

main :: IO ()
main = do
    getLine
    ns <- fmap (fromList . (map read) . words) getLine :: IO (Vector Int)
    getLine
    ms <- fmap ((map read) . words) getLine :: IO [Int]
    print $ solve ns ms

solve :: Vector Int -> [Int] -> Int
solve ns ms = snd $ foldl' bSearch (ns, 0) ms
  where
    bSearch :: (Vector Int, Int) -> Int -> (Vector Int, Int)
    bSearch (ns', c) m
        | V.null ns'     = (ns, c)
        | m == ns' ! mid = (ns, c + 1)
        | m <  ns' ! mid = bSearch ((V.take mid ns'), c) m
        | otherwise      = bSearch ((V.drop (mid + 1) ns'), c) m
      where
        mid = V.length ns' `div` 2

