import sys input = sys.stdin.readline N=int(input()) x=int(input()) A0=list(map(int,input().split())) y=int(input()) B0=list(map(int,input().split())) A0.sort(reverse=True) B0.sort() A=A0[:] while len(A)=len(B): AX=A[:len(B)] A=A[len(B):] else: AX=A[:] A=[] B=B0[:] for i in range(len(AX)): a=AX[i] ind=-1 for j in range(len(B)): if B[j]=len(A): BX=B[:len(A)] B=B[len(A):] else: BX=B[:] B=[] A=A0[:] for i in range(len(BX)): b=BX[i] ind=-1 for j in range(len(A)): if A[j]>b: ind=j if ind!=-1: A.pop(ind) ANS2+=1 else: A.pop() print(max(ANS,ANS2))