def check(N, s, M, t): i = 0 j = 0 flg = 1 ret = 1 while True: if flg: while j < M and s[i] <= t[j]: j += 1 if j == M: return ret else: while i < N and t[j] <= s[i]: i += 1 if i == N: return ret flg ^= 1 ret += 1 N = int(input()) W = list(map(int,input().split())) M = int(input()) B = list(map(int,input().split())) W.sort(reverse=True) B.sort(reverse=True) print(max(check(N, W, M, B), check(M, B, N, W)))