Nw = int(input()) Ws = list(map(int, input().split())) Nb = int(input()) Bs = list(map(int, input().split())) def solve(Bs, Ws, Nb, Nw): Ws.sort(reverse=True) Bs.sort(reverse=True) if Bs[0] > Ws[0]: Bs, Ws = Ws, Bs Nb, Nw = Nw, Nb depth = 1 idxW = 0 idxB = 0 while True: while Bs[idxB] >= Ws[idxW]: idxB += 1 if idxB == Nb: return depth depth += 1 while Ws[idxW] >= Bs[idxB]: idxW += 1 if idxW == Nw: return depth depth += 1 print(solve(Bs, Ws, Nb, Nw))