import Data.List
import Data.Function
import Control.Monad
import Control.Applicative
import Debug.Trace

toPair [x,y] = (x,y)

f (a, b) bs = do
  let s = take 1 $ sortBy (compare `on` snd) $ filter (\(x, y) -> x > a && y > b) bs
  (s, bs \\ s)

g [] bs s = reverse s
g (r:rs) bs s = do
  let (b, bs') = f r bs
  g rs bs' (b ++ s)

main = do
  n <- read <$> getLine :: IO Int
  rs <- reverse.sort <$> map (toPair.map read.words) <$> replicateM n getLine :: IO [(Int,Int)]
  bs <- reverse.sort <$> map (toPair.map read.words) <$> replicateM n getLine :: IO [(Int,Int)]
  --let rs = reverse $ sort [(1,3),(8,3)]
  --let bs = reverse $ sort [(9,4),(9,9)]
  --let rs = reverse $ sort [(2, 0), (3, 1), (1, 3)]
  --let bs = reverse $ sort [(4, 2), (0, 4), (5, 5)]
  --print $ rs
  --print $ bs
  --print $ g rs bs []
  print $ length $ g rs bs []
