n = int(input()) a = int(input()) A = list(map(int, input().split())) c = int(input()) C = list(map(int, input().split())) A_sorted = sorted(A, reverse=True) C_sorted = sorted(C) count = 0 i = 0 for _ in range(n): current_c = C_sorted[i % len(C_sorted)] if A_sorted[0] > current_c: count += 1 i += 1 print(count)