import itertools n = int(input()) m_1 = int(input()) A = list(map(int, input().split())) m_2 = int(input()) B = list(map(int, input().split())) A_ = list(itertools.accumulate(A)) B_ = [] tmp = n for x in B: tmp -= x B_.append(tmp) # print(A_) # print(B_) num_set = set(range(n + 1)) for xx in A_: num_set.discard(xx) for yy in B_: num_set.discard(yy) print(len(num_set))