#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int llint; const int INF = 1000000; const llint LINF = 100000000; int dp[100000];//何番目 int black[10000] = { 0 }, bn, wn; int white[10000] = { 0 }; int main() { int fl; cin >> wn; for (int i = 0; i < wn; i++) { cin >> white[i]; } cin >> bn; for (int i = 0; i < bn; i++) { cin >> black[i]; } int ans = 1; sort(black, black + bn,greater()); sort(white, white + wn,greater()); dp[0] = max(black[0], white[0]); if (dp[0] == black[0])fl = 1; else { fl = 2; } for (int i = 1; i < bn*wn; i++) { if (fl = 1 && dp[i - 1]>white[i]&&white[i]!=0) { dp[i] = white[i]; ans++; fl = 2; } else if (fl = 2 && dp[i - 1]>black[i]&&black[i]!=0) { dp[i] = black[i]; ans++; fl = 1; } } cout << ans << endl; return 0; }