OIG XV - pro

// https://szkopul.edu.pl/problemset/problem/iO2JdspPtx_KMGhBTCbLnKYe/site/?key=statement

#include <bits/stdc++.h>

// #define GARY_DBG
#define GARY_LIB

constexpr int sizik = 1000 * 1001;

#define ar std::array

typedef std::vector<std::vector<int>> _kra;

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> v(n);
    for (auto& a : v) {
        std::cin >> a;
    }

    int m;
    std::cin >> m;

    std::deque<int> w(m);
    for (auto& a : w) {
        std::cin >> a;
    }

    std::sort(v.begin(), v.end());
    std::sort(w.begin(), w.end());

    int ans = 0;
    for (int i = 0; i < n; i++) {
        while (!w.empty() && w.front() < v[i]) {
            w.pop_front();
        }
        if (!w.empty() && w.front() >= v[i]) {
            ans++;
            w.pop_front();
        }
    }

    std::cout << ans << '\n';
}

int32_t main() {
#ifndef GARY_DBG
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.tie(0);
#endif

    int t = 1;
    // std::cin >> t;

    for (; t > 0; t--) {
        solve();
    }

    return 0;
}