#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()); // black first -> white を探索 if (nb) ansb++; for (int i = pw; i < nw; i++){ if (w[i] < b[pb]){ ansb++; pw = i+1; pb++; if (pb == nb) break; for (int j = pb; j < nb; j ++){ if (w[i] > b[j]){ ansb++; pb = j; break; } } if (pb == nb) break; } if (pb == nb) break; } pb = 0; pw = 0; if (nw) answ++; for (int i = pb; i < nb; i++){ if (b[i] < w[pw]){ answ++; pb = i; pw++; if (pw == nw) break; for (int j = pw; j < nw; j ++){ if (b[i] > w[j]){ answ++; pw = j; break; } } if (pw == nw) break; } if (pw == nw) break; } cout << max(answ, ansb) << endl; }