On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).  A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.  At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
import math
import sys
from pprint import pprint

def distance(a,b):
    return math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2)

if __name__ == '__main__':
    N = int(input())
    reds = []
    for i in range(N):
        a,b = list(map(lambda x: int(x), input().split(" ")))
        reds.append((a,b))
    blues = []
    for i in range(N):
        c,d = list(map(lambda x: int(x), input().split(" ")))
        blues.append((c,d))
    ans = []
    reds.sort()
    blues.sort()
    while len(blues) != 0:
        for blue in blues:
            # pprint(reds)
            # pprint(blues)
            # print("------")
            red_ans = reds[0]
            min_d = sys.maxsize
            for red in reds:
                if blue[0] > red[0] and blue[1] > red[1] and (blue, red) not in ans:
                    d = distance(blue, red)
                    if min_d > d:
                        red_ans = red
                        min_d = d
            ans.append((blue, red_ans))
            blues.remove(blue)
            reds.remove(red_ans)
    print(len(ans))
    # while len(blues) == 0:
    #     blue = blues.pop()

                

from pprint import pprint
N = int(input())
reds = []
for i in range(N):
    reds.append(tuple(map(int, input().split(" "))))
blues = []
for i in range(N):
    blues.append(tuple(map(int, input().split(" "))))
reds.sort(key=lambda x: (x[1], x[0]), reverse=True)
blues.sort()
picked = [False for _ in range(N)]
ans = 0
for blue in blues:
    for i, red in enumerate(reds):
        if blue[0] > red[0] and blue[1] > red[1] and not picked[i]:
            ans += 1
            picked[i] = True
            break
print(ans)