// 400, review
fun bd092(args: Array<String>) {
    val N = args[0].toInt()
    val redList =
            args.drop(1).take(N)
                    .map { line -> line.split(" ").map { it.toInt() } }
                    .sortedByDescending { it[1] }
                    .toMutableList()
    val blueList =
            args.drop(1 + N)
                    .map { line -> line.split(" ").map { it.toInt() } }
                    .sortedBy{ it[0] }
    var cnt = 0
    blueList.forEach { blue ->
        val firstIndex = redList.indexOfFirst{ it[0] < blue[0] && it[1] < blue[1] }
        if (firstIndex != -1) {
            redList.removeAt(firstIndex)
            cnt++
        }
    }

    println(cnt)
}

fun main(args: Array<String>) {
    bd092(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}