#!/usr/bin/env python3

#ABC91 C



from operator import itemgetter

n = int(eval(input()))

red = [list(map(int,input().split())) for _ in range(n)]

blue = [list(map(int,input().split())) for _ in range(n)]

red = sorted(red,key = itemgetter(1),reverse = True)

blue = sorted(blue,key = itemgetter(0))

checkr = [True]*n

checkb = [True]*n



pair = 0

for c,d in blue:

    for j in range(n):

        a,b = red[j]

        if a < c and b < d and checkr[j]:

            pair += 1

            checkr[j] = False

            break

print(pair)

#!/usr/bin/env python3



import sys

import math

import bisect

import time

sys.setrecursionlimit(1000000000)

from heapq import heappush, heappop,heappushpop

from collections import defaultdict

from itertools import accumulate

from collections import Counter

from collections import deque

from operator import itemgetter

from itertools import permutations

mod = 10**9 + 7

inf = float('inf')

def I(): return int(sys.stdin.readline())

def LI(): return list(map(int,sys.stdin.readline().split()))



n = I()

ab = [LI() for _ in range(n)]

cd = [LI() for _ in range(n)]

ab.sort(key = itemgetter(0))

cd.sort(key = itemgetter(0))

ans = 0

for i in range(n):

    lst = []

    x,y = cd[i]

    for j in range(len(ab)):

        a,b = ab[j]

        if a <= x and b <= y:

            lst.append([a,b])

    if len(lst) == 0:

        continue

    lst.sort(key = itemgetter(1),reverse = True)

    ab.remove(lst[0])

    ans += 1

print(ans)

#!/usr/bin/env python3
# ABC91 C
from operator import itemgetter

n = int(eval(input()))
red = [list(map(int, input().split())) for _ in range(n)]
blue = [list(map(int, input().split())) for _ in range(n)]
red = sorted(red, key=itemgetter(1), reverse=True)
blue = sorted(blue, key=itemgetter(0))
checkr = [True] * n
checkb = [True] * n
pair = 0
for c, d in blue:
    for j in range(n):
        a, b = red[j]
        if a < c and b < d and checkr[j]:
            pair += 1
            checkr[j] = False
            break
print(pair)

#!/usr/bin/env python3
import sys
import math
import bisect
import time

sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations

mod = 10**9 + 7
inf = float("inf")


def I():
    return int(sys.stdin.readline())


def LI():
    return list(map(int, sys.stdin.readline().split()))


n = I()
ab = [LI() for _ in range(n)]
cd = [LI() for _ in range(n)]
ab.sort(key=itemgetter(0))
cd.sort(key=itemgetter(0))
ans = 0
for i in range(n):
    lst = []
    x, y = cd[i]
    for j in range(len(ab)):
        a, b = ab[j]
        if a <= x and b <= y:
            lst.append([a, b])
    if len(lst) == 0:
        continue
    lst.sort(key=itemgetter(1), reverse=True)
    ab.remove(lst[0])
    ans += 1
print(ans)

-# ABC91 C +import sys +import math +import bisect +import time + +sys.setrecursionlimit(1000000000) +from heapq import heappush, heappop, heappushpop +from collections import defaultdict +from itertools import accumulate +from collections import Counter +from collections import deque +from itertools import permutations -n = int(eval(input())) -red = [list(map(int, input().split())) for _ in range(n)] -blue = [list(map(int, input().split())) for _ in range(n)] -red = sorted(red, key=itemgetter(1), reverse=True) -blue = sorted(blue, key=itemgetter(0)) -checkr = [True] * n -checkb = [True] * n -pair = 0 -for c, d in blue: -    for j in range(n): -        a, b = red[j] -        if a < c and b < d and checkr[j]: -            pair += 1 -            checkr[j] = False -            break -print(pair) +mod = 10**9 + 7 +inf = float("inf") + + +def I(): +    return int(sys.stdin.readline()) + + +def LI(): +    return list(map(int, sys.stdin.readline().split())) + + +n = I() +ab = [LI() for _ in range(n)] +cd = [LI() for _ in range(n)] +ab.sort(key=itemgetter(0)) +cd.sort(key=itemgetter(0)) +ans = 0 +for i in range(n): +    lst = [] +    x, y = cd[i] +    for j in range(len(ab)): +        a, b = ab[j] +        if a <= x and b <= y: +            lst.append([a, b]) +    if len(lst) == 0: +        continue +    lst.sort(key=itemgetter(1), reverse=True) +    ab.remove(lst[0]) +    ans += 1 +print(ans)