#include #include #include using namespace std; long long DP[1000001]; int main() { int nw; cin >> nw; vectorW(nw); for (int i = 0; i < nw; i++)cin >> W[i]; int nb; cin >> nb; vectorB(nb); for (int i = 0; i < nb; i++)cin >> B[i]; bool BW; BW = true; int cntW=1; for (int i = W.back() -1; i > 0; i--) { if (BW) { if (find(B.begin(), B.end(), i)!=B.end()) { BW = !BW; cntW++; } } else { if (find(W.begin(), W.end(), i)!=W.end()) { BW = !BW; cntW++; } } } BW = false; int cntB=1; for (int i = B.back() - 1; i > 0; i--) { if (BW) { if (find(B.begin(), B.end(), i) != B.end()) { BW = !BW; cntB++; } } else { if (find(W.begin(), W.end(), i) != W.end()) { BW = !BW; cntB++; } } } cout << max(cntW,cntB) << endl; return 0; }