import java.io.FileInputStream
import java.util.*


var sc: Scanner = Scanner(System.`in`)
fun main(args: Array<String>) {
    if (args.size > 0) {
        System.setIn(FileInputStream(args[0]))
    }
    sc = Scanner(System.`in`)

    problem()

}

fun problem() {

    val N = sc.nextInt()
    sc.nextLine()
    val reds = mutableListOf<Pair<Int, Int>>()
    for (a in 1..N) {
        val x = sc.nextInt()
        val y = sc.nextInt()
        reds.add(x to y)
    }

    reds.sortBy { it.second }
    reds.sortBy { it.first }
    //println(reds)

    val brues = mutableListOf<Pair<Int, Int>>()
    for (a in 1..N) {
        val x = sc.nextInt()
        val y = sc.nextInt()
        brues.add(x to y)
    }

    brues.sortBy { it.second }
    brues.sortBy { it.first }

    //println(brues)
    println(search(reds, brues, 0))

}

fun search(reds: MutableList<Pair<Int, Int>>, brues: MutableList<Pair<Int, Int>>, count: Int): Int {
    if (reds.size == 0 || brues.size == 0) {
        return count
    }
    var maxcount = count
    for (i in 0..(reds.size - 1)) {
        var red = reds[i]
        for (j in 0..(brues.size - 1)) {

            var brue = brues[j]
            if (red.first < brue.first && red.second < brue.second) {
                reds.removeAt(i)
                brues.removeAt(j)

                val newcount = search(reds, brues, count + 1)
                if (newcount > maxcount) {
                    maxcount = newcount
                }
                reds.add(i, red)
                brues.add(j, brue)
            }
        }
    }
    return maxcount
}
