from itertools import accumulate N = int(input()) M = int(input()) A = list(map(int, input().split())) L = int(input()) B = list(map(int, input().split())) S = set(accumulate(A, initial=0)) T = set(accumulate(B, initial=0)) U = S | T print(N + 1 - len(U))