from collections import defaultdict



n=int(eval(input()))

ab=[[int(i) for i in input().split()] for j in range(n)]

cd=[[int(i) for i in input().split()] for j in range(n)]

ab.sort()

cd.sort()

    

ans=0



for i in cd:

    check=-1

    pair=[-1,-1]

    for j in ab:

        

        if j[0]>i[0]:

            break

        if check<j[1]<i[1]:

            check=j[1]

            pair=j

    if pair != [-1,-1]:

        ans+=1

        ab.remove(pair)

print(ans)

    
import bisect

n=int(eval(input()))

ab=[[int(i) for i in input().split()] for j in range(n)]

cd=[[int(i) for i in input().split()] for j in range(n)]

ab.sort()

cd.sort()



ans=0



for c,d in cd:

    now_y=-1

    check=False

    for a,b in ab:

        if a>=c:

            break

        if b<d and b>now_y:

            now_id=bisect.bisect_left(ab,[a,b])

            now_y=b

            check=True



    if check:

        ans+=1

        ab.pop(now_id)

print(ans)

            

        

from collections import defaultdict

n = int(eval(input()))
ab = [[int(i) for i in input().split()] for j in range(n)]
cd = [[int(i) for i in input().split()] for j in range(n)]
ab.sort()
cd.sort()
ans = 0
for i in cd:
    check = -1
    pair = [-1, -1]
    for j in ab:
        if j[0] > i[0]:
            break
        if check < j[1] < i[1]:
            check = j[1]
            pair = j
    if pair != [-1, -1]:
        ans += 1
        ab.remove(pair)
print(ans)

import bisect

n = int(eval(input()))
ab = [[int(i) for i in input().split()] for j in range(n)]
cd = [[int(i) for i in input().split()] for j in range(n)]
ab.sort()
cd.sort()
ans = 0
for c, d in cd:
    now_y = -1
    check = False
    for a, b in ab:
        if a >= c:
            break
        if b < d and b > now_y:
            now_id = bisect.bisect_left(ab, [a, b])
            now_y = b
            check = True
    if check:
        ans += 1
        ab.pop(now_id)
print(ans)

-from collections import defaultdict +import bisect -for i in cd: -    check = -1 -    pair = [-1, -1] -    for j in ab: -        if j[0] > i[0]: +for c, d in cd: +    now_y = -1 +    check = False +    for a, b in ab: +        if a >= c: -        if check < j[1] < i[1]: -            check = j[1] -            pair = j -    if pair != [-1, -1]: +        if b < d and b > now_y: +            now_id = bisect.bisect_left(ab, [a, b]) +            now_y = b +            check = True +    if check: -        ab.remove(pair) +        ab.pop(now_id)