import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import qualified Data.Set as Set
import qualified Data.Sequence as Sq
import qualified Data.IntMap as IMap
import qualified Data.Vector as V
import Data.Sequence (ViewL(..),ViewR(..),(><),(<|),(|>),Seq)

bsreadInt :: BC.ByteString -> Int
bsreadInt = fst . fromJust . BC.readInt

sqleft :: Seq a -> a
sqleft q = sqleft_(Sq.viewl q)
sqleft_ :: ViewL a -> a
sqleft_ (x :< xs) = x
sqright :: Seq a -> a
sqright q = sqright_(Sq.viewr q)
sqright_ :: ViewR a -> a
sqright_ (xs :> x) = x
--------------------------------------------------------------
tsort xs = reverse $ map reverse $ sort  $ map (reverse) xs
alt :: Int -> [Int] -> Bool
alt k an = if k <= (head an) then True else False

ans :: [[Int]] -> [[Int]] -> Int
ans xn [] = 0
ans [] yn = 0
ans (x:xn) (y:yn) = if a >= c
                    then ans xn (y:yn)
                    else 1 + ans xn (reverse (sort ( (y:yn) \\ [m]) ))
                      where a = x !! 0
                            b = x !! 1
                            c = y !! 0
                            d = y !! 1
                            m = head $ reverse $ tsort $ filter (alt a) (y:yn)

main = do
    n <- readLn :: IO Int
    ab <- map ((map bsreadInt . BC.words)) <$> replicateM n BC.getLine
    cd <- map ((map bsreadInt . BC.words)) <$> replicateM n BC.getLine
    
    print $ ans (reverse (sort ab)) (reverse (sort cd))
    