from bisect import bisect_left as bl , bisect_right as br s=int(input()) ss=list(map(int,input().split())) ss.sort() k=int(input()) kk=list(map(int,input().split())) kk.sort() def cal(x,f): cnt=1 while True: if f%2 == 0: t=bl(kk,x)-1 x=kk[t] else: t=bl(ss,x)-1 x=ss[t] if t == -1: return cnt cnt += 1 f += 1 S=cal(ss[-1],0) K=cal(kk[-1],1) print(max(S,K))