import java.util.Scanner

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val n = scanner.nextInt()
	val rs = Array(n){Pair(scanner.nextInt(), scanner.nextInt())}
	val bs = mutableListOf<Pair<Int, Int>>()
	repeat(n){bs.add(Pair(scanner.nextInt(), scanner.nextInt()))}

	rs.sortByDescending { Math.max(it.first, it.second) }
	bs.sortBy { Math.min(it.first, it.second) }
	var ans = 0

	for (r in rs) {
		for (b in bs){
			if (r.first<b.first && r.second<b.second) {
				ans++
				bs.remove(b)
				break
			}
		}
	}
	println(ans)
}