import sys input=lambda:sys.stdin.readline().rstrip() N=int(input()) a=list(map(int,input().split())) for i in range(1,3): a[i]+=a[i-1] ans=0 S=[0]+list(map(len,input().split())) for i in range(1,N+1): S[i]+=S[i-1] S=set(S) for i in S: ans+=all([(i+j in S) for j in a]) print(ans)