import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y", bool, "haspair");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto red = new Pair[](n);
    auto blue = new Pair[](n);
    foreach (i; iota(n))
    {
        long a, b;
        scan(a, b);
        red[i] = Pair(a, b, false);
    }
    foreach (j; iota(n))
    {
        long c, d;
        scan(c, d);
        blue[j] = Pair(c, d, false);
    }
    red.sort!"a.x<b.x"();
    blue.sort!"a.x<b.x"();
    long count;
    foreach (i; iota(n))
    {
        long maxy = -1;
        foreach (j; iota(n))
        {
            if (red[j].x > blue[i].x)
                break;

            if (red[j].haspair)
                continue;

            if (maxy < 0 || red[j].y > red[maxy].y)
            {
                if (red[j].y < blue[i].y)
                    maxy = j;
            }
        }
        if (maxy >= 0)
        {
            red[maxy].haspair = true;
            count++;
        }
    }
    count.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
