import java.math.*
import java.util.BitSet

class FordFulkerson(val N: Int) {
    // 辺の配列
    // 容量は別に持つため、ここでは終点のリストのみ持つ
    val edges = Array(N, {mutableListOf<Int>()})
    val capacity = Array(N, {IntArray(N, {-1})})
    val used = BitSet(N)
    
    private fun dfs(s: Int, d: Int, flow: Int): Int {
        used.set(s)
        
        if (s == d) {
            return flow
        }
        
        for (e in edges[s]) {
            if (!used.get(e) && capacity[s][e] > 0) {
                val flowTmp = dfs(e, d, Math.min(capacity[s][e], flow))
                if (flowTmp > 0) {
                    capacity[s][e] -= flowTmp
                    capacity[e][s] += flowTmp
                    return flowTmp
                }
            }
        }
        
        return 0
    }
    
    fun add(from: Int, to: Int, cap: Int) {
        edges[from].add(to)
        edges[to].add(from)
        capacity[from][to] = cap
        capacity[to][from] = 0
    }
    
    fun solve(source: Int, sink: Int): Int {
        var flow = 0
        while (true) {
            used.clear()
            
            val flowTmp = dfs(source, sink, Int.MAX_VALUE)
            
            if (flowTmp == 0) {
                break
            }
            
            flow += flowTmp
        }
        return flow
    }
}

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    // フォード・ファルカーソンで解く
    // 0をsource, 2N + 1をsinkとするため、2N + 2のノードを用意する
    val ff = FordFulkerson(N * 2 + 2)
    
    val red = (1..N).map {val (a, b) = readInputLine().split(" ").map{it.toInt()}; Pair(a, b)}
    val blue = (1..N).map {val (c, d) = readInputLine().split(" ").map{it.toInt()}; Pair(c, d)}
    
    for (i in 1..N) {
        ff.add(0, i, 1)
        ff.add(N + i, N * 2 + 1, 1)
    }
    
    for ((i, r) in red.withIndex()) {
        for ((j, b) in blue.withIndex()) {
            if (r.first < b.first && r.second < b.second) {
                ff.add(i + 1, j + N + 1, 1)
            }
        }
    }
    
    println(ff.solve(0, N * 2 + 1))
}

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