def pyramid(Nw, W, Nb, B): pyli = [] W_max = max(W) B_max = max(B) if (W_max < B_max) or ((W_max == B_max) and (len(W) > len(B))): W_max, B_max = B_max, W_max W, B = B, W pyli.append(W_max) W.pop(W.index(W_max)) for i in range(10): if len(B) == 0: break for j in range(len(B)): B_max = max(B) if B_max < pyli[-1]: pyli.append(B_max) B.pop(B.index(B_max)) break else: B.pop(B.index(B_max)) else: break if len(W) == 0: break for k in range(len(W)): W_max = max(W) if W_max < pyli[-1]: pyli.append(W_max) W.pop(W.index(W_max)) break else: W.pop(W.index(W_max)) else: break ans = len(pyli) return ans def main(): Nw = int(input()) W = list(map(int, input().split())) Nb = int(input()) B = list(map(int, input().split())) print(pyramid(Nw, W, Nb, B)) if __name__ == '__main__': main()