import qualified Data.Map as M
import Data.List

f :: [String]->[(Int,Int)]
f []=[]
f (x:xs) =let (a:b:[])=map read (words x)::[Int]
          in (a,b):f xs

f3 ::[Int]->Int->Int
f3 xs rx=if null (dropWhile (>= rx) xs) then (-1) else head (dropWhile (>= rx) xs)  

f2::[Int]->[(Int,Int)]->[(Int,Int)]->[Int]
f2 _ _ [] =[]
f2 xs [] ((_,rx):rs)=let tx=f3 xs rx
                     in if tx==(-1) then 0:f2 xs [] rs else 1:f2 (delete tx xs) [] rs
f2 xs allbs@((by,bx):bs) allrs@((ry,rx):rs)
        |by<ry=f2 (reverse (sort (bx:xs))) bs allrs
        |otherwise=let tx=f3 xs rx
                   in if tx==(-1) then 0:f2 xs allbs rs else 1:f2 (delete tx xs) allbs rs


main = do
        e<-getLine
        e2<-getContents
        let n=read e::Int
            xs=lines e2
            bs=take n xs
            rs=drop n xs
            bs2=sort $ f bs
            rs2=sort $ f rs
        putStrLn $ show $ sum $ f2 [] bs2 rs2 