import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

alias Point = Tuple!(int, "x", int, "y", int, "c");

void main() {
    int n;
    scan(n);
    auto ps = new Point[](2*n);
    foreach (i ; 0 .. 2*n) {
        int ai, bi;
        scan(ai, bi);
        ps[i] = Point(ai, bi, (i < n ? 0 : 1));
    }
    ps.sort!"a.x < b.x"();

    int ans;
    auto cnt = new int[](2*n + 1);
    foreach (i ; 0 .. 2*n) {
        if (ps[i].c == 0) {
            cnt[ps[i].y]++;
        }
        else {
            foreach_reverse (h ; 0 .. ps[i].y) {
                if (cnt[h] > 0) {
                    cnt[h]--;
                    ans++;
                    break;
                }
            }
        }
    }
    writeln(ans);
}
































void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
