import networkx as nx

from networkx.algorithms.flow import dinitz



N = int(eval(input()))

reds = [tuple(map(int, input().split())) for _ in range(N)]

blues = [tuple(map(int, input().split())) for _ in range(N)]

G = nx.DiGraph()

for rx, ry in reds:

    for bx, by in blues:

        if rx < bx and ry < by:

            G.add_edge("S", (rx, ry), capacity=1)

            G.add_edge((rx, ry), (bx, by), capacity=1)

            G.add_edge((bx, by), "T", capacity=1)

if G.nodes:

    R = dinitz(G, "S", "T")

    print((R.graph["flow_value"]))

else:

    print((0))



import networkx as nx



N = int(eval(input()))

reds = [tuple(map(int, input().split())) for _ in range(N)]

blues = [tuple(map(int, input().split())) for _ in range(N)]

G = nx.DiGraph()

for rx, ry in reds:

    for bx, by in blues:

        if rx < bx and ry < by:

            G.add_edge("S", (rx, ry), capacity=1)

            G.add_edge((rx, ry), (bx, by), capacity=1)

            G.add_edge((bx, by), "T", capacity=1)

if G.nodes:

    print((nx.maximum_flow_value(G, "S", "T")))

else:

    print((0))
import networkx as nx
from networkx.algorithms.flow import dinitz

N = int(eval(input()))
reds = [tuple(map(int, input().split())) for _ in range(N)]
blues = [tuple(map(int, input().split())) for _ in range(N)]
G = nx.DiGraph()
for rx, ry in reds:
    for bx, by in blues:
        if rx < bx and ry < by:
            G.add_edge("S", (rx, ry), capacity=1)
            G.add_edge((rx, ry), (bx, by), capacity=1)
            G.add_edge((bx, by), "T", capacity=1)
if G.nodes:
    R = dinitz(G, "S", "T")
    print((R.graph["flow_value"]))
else:
    print((0))

import networkx as nx

N = int(eval(input()))
reds = [tuple(map(int, input().split())) for _ in range(N)]
blues = [tuple(map(int, input().split())) for _ in range(N)]
G = nx.DiGraph()
for rx, ry in reds:
    for bx, by in blues:
        if rx < bx and ry < by:
            G.add_edge("S", (rx, ry), capacity=1)
            G.add_edge((rx, ry), (bx, by), capacity=1)
            G.add_edge((bx, by), "T", capacity=1)
if G.nodes:
    print((nx.maximum_flow_value(G, "S", "T")))
else:
    print((0))

-from networkx.algorithms.flow import dinitz -    R = dinitz(G, "S", "T") -    print((R.graph["flow_value"])) +    print((nx.maximum_flow_value(G, "S", "T")))