#include #include #include #include #include #include #include #include #include #include #include using ll = long long; using namespace std; int main(){ int nw, nb, pw = 0, pb = 0, answ = 0, ansb = 0; cin >> nw; vector w(nw); for (int i = 0; i < nw; i++) cin >> w[i]; cin >> nb; vector b(nb); for (int i = 0; i < nb; i++) cin >> b[i]; sort(w.begin(), w.end(), greater()); sort(b.begin(), b.end(), greater()); for (int i = pw; i < nw; i++){ if ((i == 0) || w[i] < b[pb]){ answ++; pw = i + 1; if (i != 0) pb++; if (pb == nb) break; for (int j = pb; j < nb; j ++){ if (w[i] > b[j]){ answ++; pb = j; break; } } } } pw = 0; pb = 0; for (int i = 0; i < nb; i++){ if ((i == 0) || b[i] < w[pw]){ ansb++; pb = i + 1; if (i != 0) pw++; if (pw == nw) break; for (int j = pw; j < nw; j ++){ if (b[i] > w[j]){ ansb++; pw = j; break; } } } } cout << max(answ, ansb) << endl; }