fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    val red = mutableListOf<Pair<Int, Int>>()
    val blue = mutableListOf<Pair<Int, Int>>()
    
    for (i in 1..N) {
        val (a, b) = readInputLine().split(" ").map {it.toInt()}
        red.add(Pair(a, b))
    }
    for (i in 1..N) {
        val (c, d) = readInputLine().split(" ").map {it.toInt()}
        blue.add(Pair(c, d))
    }
    
    red.sortByDescending { it.second }
    blue.sortBy { it.first }

    val used = mutableSetOf<Pair<Int, Int>>()

    for (bElem in blue) {
        for (rElem in red) {
            if (used.contains(rElem)) {
                continue
            }
            if (rElem.first < bElem.first && rElem.second < bElem.second) {
                used.add(rElem)
                break
            }
        }
    }
    
    println(used.size)
}

fun readInputLine(): String {
    return readLine()!!
}
