from bisect import bisect_right NW = int(input()) W = sorted(map(int, input().split())) NB = int(input()) B = sorted(map(int, input().split())) WB = [W, B] ans = 0 for i in range(2): lim = min(NW, NB)*2 + (NW != NB) blk = 0 h = 0 for j in range(lim): wb = (i + j) % 2 p = bisect_right(WB[wb], blk) if p >= len(WB[wb]): break h += 1 blk = WB[wb][p] ans = max(ans, h) print(ans)