# coding: utf-8 # Your code here! N=int(input()) M1=int(input()) A=list(map(int,input().split())) M2=int(input()) B=list(map(int,input().split())) stairs=[1]*(N+1) stairs[0]=0 now=0 for a in A: now+=a stairs[now]=0 for b in B: now-=b stairs[now]=0 print(sum(stairs))