def main():

    N = int(eval(input()))

    points = []

    for _ in range(N):

        x, y = list(map(int, input().split()))

        points.append((x, y, "r"))

    for _ in range(N):

        x, y = list(map(int, input().split()))

        points.append((x, y, "b"))

    points.sort(lambda x: x[0])

    singles = []

    retval = 0

    for p in points:

        x, y, c = p

        if c == "r":

            singles.append(y)

        if c == "b":

            maximum = (-1, -1)

            for i, v in enumerate(singles):

                if v < y and v > maximum[1]:

                    maximum = (i, v)

            if maximum[0] != -1:

                retval += 1

                singles.pop(maximum[0])

    print(retval)





if __name__ == "__main__":

    main()

import heapq





def main():

    N = int(eval(input()))

    R = [list(map(int, input().split())) + ['R'] for _ in range(N)]

    B = [list(map(int, input().split())) + ['B'] for _ in range(N)]

    P = R + B

    P.sort(key=lambda x: (x[0], x[1]))

    solo = []

    ans = 0

    for p in P:

        x, y, c = p

        if c == 'R':

            solo.append((x, y))

        else:

            tmp = (-1, -1)

            for s in solo:

                if s[0] < x and tmp[1] < s[1] < y:

                    tmp = s

            if tmp != (-1, -1):

                solo.remove(tmp)

                ans += 1

    print(ans)





if __name__ == "__main__":

    main()

def main():
    N = int(eval(input()))
    points = []
    for _ in range(N):
        x, y = list(map(int, input().split()))
        points.append((x, y, "r"))
    for _ in range(N):
        x, y = list(map(int, input().split()))
        points.append((x, y, "b"))
    points.sort(lambda x: x[0])
    singles = []
    retval = 0
    for p in points:
        x, y, c = p
        if c == "r":
            singles.append(y)
        if c == "b":
            maximum = (-1, -1)
            for i, v in enumerate(singles):
                if v < y and v > maximum[1]:
                    maximum = (i, v)
            if maximum[0] != -1:
                retval += 1
                singles.pop(maximum[0])
    print(retval)


if __name__ == "__main__":
    main()

import heapq


def main():
    N = int(eval(input()))
    R = [list(map(int, input().split())) + ["R"] for _ in range(N)]
    B = [list(map(int, input().split())) + ["B"] for _ in range(N)]
    P = R + B
    P.sort(key=lambda x: (x[0], x[1]))
    solo = []
    ans = 0
    for p in P:
        x, y, c = p
        if c == "R":
            solo.append((x, y))
        else:
            tmp = (-1, -1)
            for s in solo:
                if s[0] < x and tmp[1] < s[1] < y:
                    tmp = s
            if tmp != (-1, -1):
                solo.remove(tmp)
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

+import heapq + + -    points = [] -    for _ in range(N): -        x, y = list(map(int, input().split())) -        points.append((x, y, "r")) -    for _ in range(N): -        x, y = list(map(int, input().split())) -        points.append((x, y, "b")) -    points.sort(lambda x: x[0]) -    singles = [] -    retval = 0 -    for p in points: +    R = [list(map(int, input().split())) + ["R"] for _ in range(N)] +    B = [list(map(int, input().split())) + ["B"] for _ in range(N)] +    P = R + B +    P.sort(key=lambda x: (x[0], x[1])) +    solo = [] +    ans = 0 +    for p in P: -        if c == "r": -            singles.append(y) -        if c == "b": -            maximum = (-1, -1) -            for i, v in enumerate(singles): -                if v < y and v > maximum[1]: -                    maximum = (i, v) -            if maximum[0] != -1: -                retval += 1 -                singles.pop(maximum[0]) -    print(retval) +        if c == "R": +            solo.append((x, y)) +        else: +            tmp = (-1, -1) +            for s in solo: +                if s[0] < x and tmp[1] < s[1] < y: +                    tmp = s +            if tmp != (-1, -1): +                solo.remove(tmp) +                ans += 1 +    print(ans)