# import pypyjit # pypyjit.set_param('max_unroll_recursion=-1') from collections import * from itertools import * from functools import * from heapq import * import sys,math # input = sys.stdin.readline N = int(input()) M1 = int(input()) A = list(map(int,input().split())) M2 = int(input()) B = list(map(int,input().split())) dp = [False]*(N+1) dp[0]=True dp[N] = True now = 0 for a in A: now += a dp[now] = True now = N for b in B: now -= b dp[now] = True print(N+1-sum(dp))