import Control.Monad
import Data.List
import qualified Data.Set as S
f m _ _ [] = m
f m s ([a,b]:rs) bs@([c,d]:_) 
  | a < c = f m (S.insert b s) rs bs
f m s rs ([c,d]:bs) 
  | Just x <- S.lookupLT d s = f (m+1) (S.delete x s) rs bs
  | otherwise = f m s rs bs
main = do
  n <- readLn
  rs <- replicateM n $ map read . words <$> getLine :: IO [[Int]]
  bs <- replicateM n $ map read . words <$> getLine :: IO [[Int]]
  print $ f 0 S.empty (sort rs) (sort bs)