nw = int(input()) W = list(map(int, input().split())) nb = int(input()) B = list(map(int, input().split())) def get_height(base, next_color): m = [] i = max(base) m.append(i) while True: next_color = [k for k in next_color if k < i] if next_color == []: break i = max(next_color) m.append(i) base = [s for s in base if s < i] if base == []: break i = max(base) m.append(i) return len(m) WC = W[:] BC = B[:] if __name__ == '__main__': white = get_height(WC, BC) black = get_height(BC, WC) print(max(white, black))