INF = 1 << 60 input() W = list(map(int, input().split())) input() B = list(map(int, input().split())) def f(x, ai, a, bi, b) -> int: # x の上に a を積む for i in range(ai, len(a)): if a[i] < x: return f(a[i], bi, b, i+1, a) + 1 return 0 W.sort(reverse=True) B.sort(reverse=True) ans = max(f(INF, 0, W, 0, B), f(INF, 0, B, 0, W)) print(ans)