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