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