import sys from bisect import bisect_left, bisect_right read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N = int(readline()) A = int(readline()) B0 = list(map(int, readline().split())) C = int(readline()) D0 = list(map(int, readline().split())) B0.sort() D0.sort() def game(): B = [] D = [] for _ in range(N): if not B: B += B0 if not D: D += D0 if len(B) <= len(D): x = B.pop() i = bisect_left(D, x) y = D.pop(i - 1) yield x, y else: y = D.pop(0) i = bisect_right(B, y) if i == len(B): x = B.pop(0) else: x = B.pop(i) yield x, y answer = sum(x > y for x, y in game()) print(answer)