{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Control.Monad                    (forM, replicateM)
import           Control.Monad.Trans.State.Strict (State, execState, get, put)
import qualified Data.ByteString.Char8            as BC
import           Data.List                        (delete, sort, sortOn)
import           Data.Maybe                       (fromJust)

main :: IO ()
main = do
  n <- readLn
  abs <- replicateM n getInt2
  cds <- replicateM n getInt2
  print $ solve n abs cds

solve :: Int -> [(Int, Int)] -> [(Int, Int)] -> Int
solve n abs cds = n - m where
  m = length . flip execState abs $
        forM (sort cds) deleteFriend

deleteFriend :: (Int, Int) -> State [(Int, Int)] ()
deleteFriend cd = do
  abs <- get
  let fs = reverse . sortOn snd $ filter (dominate cd) abs
  if null fs
    then return ()
    else put $ delete (head fs) abs

dominate :: (Int, Int) -> (Int, Int) -> Bool
dominate (c, d) (a, b) = a < c && b < d

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine

getInt2 :: IO (Int, Int)
getInt2 = (\[a, b] -> (a, b)) <$> getInts
