def solve(w, h, xs, ys): if not xs: return h if xs[0] <= w: return solve(w, h, xs[1:], ys) else: return solve(xs[0], h + 1, ys, xs[1:]) _ = input() W = sorted(map(int, raw_input().strip().split())) _ = input() B = sorted(map(int, raw_input().strip().split())) print(max(solve(0, 0, W, B), solve(0, 0, B, W)))