from itertools import accumulate from operator import sub N = int(input()) M = int(input()) A = list(map(int, input().split())) L = int(input()) B = list(map(int, input().split())) S = set(accumulate(A, initial=0)) T = set(accumulate(B, initial=N, func=sub)) U = S | T print(N + 1 - len(U))