n = int(input()) w = sorted([int(i) for i in input().split()]) m = int(input()) b = sorted([int(i) for i in input().split()]) def dfs(n,m,s,c): ret = 0 if c == 0: for i in range(n,-1,-1): if w[i] < s: ret = max(ret,dfs(i-1,m,w[i],(c+1)&1)+1) else: for i in range(m,-1,-1): if b[i] < s: ret = max(ret,dfs(n,i-1,b[i],(c+1)&1)+1) return ret print(max(dfs(n-1,m-1,10**9,0),dfs(n-1,m-1,10**9,1)))