module main; import std; void main() { // 入力 int NW = readln.chomp.to!int; auto W = readln.split.to!(int[]); int NB = readln.chomp.to!int; auto B = readln.split.to!(int[]); // 答えの計算 int ans = 0; W.sort!"a > b"; B.sort!"a > b"; // 白から積んでいく int curW = 0, curB = 0, tmp = 1; while (true) { while (curB < NB && B[curB] >= W[curW]) curB++; if (curB == NB) break; ++tmp; while (curW < NW && W[curW] >= B[curB]) curW++; if (curW == NW) break; ++tmp; } ans = max(ans, tmp); // 黒から積んでいく curW = 0, curB = 0, tmp = 1; while (true) { while (curW < NW && W[curW] >= B[curB]) curW++; if (curW == NW) break; ++tmp; while (curB < NB && B[curB] >= W[curW]) curB++; if (curB == NB) break; ++tmp; } ans = max(ans, tmp); // 答えの出力 writeln(ans); }