import java.util.*
import kotlin.*


fun main(args: Array<String>){
    var line: String = readLine() as String
    val n = line.toInt()
    val red =ArrayList<IntArray>()
    for(i in 0 until n){
        val a=readLine()!!.split(" ")
        red.add(intArrayOf(a[0].toInt(),a[1].toInt()))
    }

    val blue = PriorityQueue<IntArray>(n,Comparator<IntArray>{ o1:IntArray, o2:IntArray -> o1[0]-o2[0] })
    for(i in 0 until n){
        val a=readLine()!!.split(" ")
        blue.add(intArrayOf(a[0].toInt(),a[1].toInt()))
    }

    red.sortBy { it:IntArray->it[1] }//y座標でソート
    var count=0
    while (true){
        val next = blue.poll() ?: break
        var index=red.size-1
        while(index>=0){
            if(red[index][0]<next[0]&&red[index][1]<next[1]){
                count+=1
                red.removeAt(index)
                break
            }
            index -= 1
        }
        if(red.size==0){
            break
        }
    }
    print(count)
}
