N = int(input()) M1 = int(input()) A = list(map(int, input().split())) M2 = int(input()) B = list(map(int, input().split())) flag = [False]*(N+1) now = 0 for a in A: now += a flag[now] = True for b in B: now -= b flag[now] = True print(N+1-sum(flag))