#include "bits/stdc++.h"

using namespace std;

constexpr int MOD = 1000000007;

using Long = long long;
template<typename T>
using V = vector<T>;
template<typename T>
using Vv = V<V<T>>;
using Vb = V<bool>;
using Vvb = V<Vb>;
using Vi = V<int>;
using Vvi = V<Vi>;
using Vl = V<Long>;
using Vvl = V<Vl>;
using Vd = V<double>;
using Vvd = V<Vd>;
using Vs = V<string>;

template<typename T>
T read() {
    T res;
    cin >> res;
    return res;
}

template<typename T>
V<T> readV(int n) {
    V<T> res((size_t) n);
    for (int i = 0; i < n; ++i) {
        res[i] = read<T>();
    }
    return res;
}

template<typename T>
Vv<T> readVv(int n, int m) {
    Vv<T> res((size_t) n, V<T>((size_t) m));
    for (int i = 0; i < n; ++i) {
        res[i] = readV<T>(m);
    }
    return res;
}

template <typename X>
inline size_t hash(const X& x) {
    return std::hash<X>{}(x);
}

template <typename X, typename Y>
inline size_t hash(const X& x, const Y& y) {
    auto a = ::hash(x);
    auto b = ::hash(y);
    return a ^ (b + 0x9e3779b9 + (a << 6u) + (a >> 2u));
};

template <typename X, typename Y, typename... Z>
size_t hash(const X& x, const Y& y, const Z&... z) {
    return ::hash(::hash(x, y), z...);
}

namespace Private {
    template<typename... X, size_t... I>
    inline size_t hash_tuple(const tuple<X...>& x, index_sequence<I...>) {
        return ::hash(get<I>(x)...);
    }

    template<typename X, size_t N, size_t... I>
    inline size_t hash_array(const array<X, N>& x, index_sequence<I...>) {
        return ::hash(x[I]...);
    }
}

namespace std {
    template<typename F, typename S>
    struct hash<pair<F, S>> {
        size_t operator()(const pair<F, S>& x) const {
            return ::hash(x.first, x.second);
        }
    };

    template<typename... X>
    struct hash<tuple<X...>> {
        size_t operator()(const tuple<X...>& x) const {
            return Private::hash_tuple(x, index_sequence_for<X...>{});
        }
    };

    template<typename X, size_t N>
    struct hash<array<X, N>> {
        size_t operator()(const array<X, N>& x) const {
            return Private::hash_array(x, make_index_sequence<N>{});
        }
    };

    template<typename X>
    struct hash<vector<X>> {
        size_t operator()(const vector<X>& x) const {
            size_t ans = 0;
            for (const auto& a : x) {
                ans = ::hash(ans, a);
            }
            return ans;
        }
    };
}

// *** SOLUTION BEGIN ***

void solve() {
    int n;
    cin >> n;
    V<pair<int, int>> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i].first >> b[i].second;
    }
    sort(begin(a), end(a));
    sort(begin(b), end(b));
    auto q = begin(a);
    set<int> s;
    int ans = 0;
    for (auto p : b) {
        while (q != end(a) && q->first < p.first) {
            s.insert(q->second);
            q++;
        }
        auto t = s.lower_bound(p.second);
        if (t != s.begin()) {
            s.erase(--t);
            ans++;
        }
    }
    cout << ans;
}

// *** SOLUTION END ***

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
    solve();
    return 0;
}


Measured memory_bytes: 256