N = int(input()) M1 = int(input()) A = list(map(int,input().split())) M2 = int(input()) B = list(map(int,input().split())) import itertools A_sum = list(itertools.accumulate(A)) B_sum = list(itertools.accumulate(B)) li = A_sum + [N-B[i] for i in range(M2)] + [0] print(N+1-len(set(li)))