N = int(input()) M1 = int(input()) A = list(map(int, input().split())) M2 = int(input()) B= list(map(int, input().split())) cnt = 0 s = set([0]) for a in A: cnt += a s.add(cnt) for b in B: cnt -= b s.add(cnt) print(N+1-len(s))