import Control.Monad
import Data.List
import Data.Function

main = do
 n <- readLn
 ab_s <- foo n
 cd_s <- foo n
 print $ analyze (sortOn fst ab_s) (sortOn fst cd_s)

foo n = forM [1..n] $ \_ -> do
 [a,b] <- map read . words <$> getLine
 return (a,b)
type Point = (Int, Int)

analyze :: [Point] -> [Point] -> Int
analyze reds [] = 0
analyze reds ((c,d):bls) = case reverse $ sortOn snd [(a,b) | (a,b) <- reds, a<=c, b<=d] of
 [] -> analyze reds bls
 (r:_) -> 1 + analyze (filter (/=r) reds) bls

