def solve(a,b): res = [10**9] j = len(b)-1 for i in a[::-1]: if i >= res[-1]: continue res.append(i) while j >= 0: if b[j] < res[-1]: res.append(b[j]) break j -= 1 if j == -1: break return len(res)-1 n = int(input()) *w, = map(int,input().split()) m = int(input()) *b, = map(int,input().split()) w.sort() b.sort() ans = max(solve(w,b),solve(b,w)) print(ans)