n=int(input()) a,b,c=map(int,input().split()) s=list(map(str,input().split())) t=[len(i) for i in s] def f(m): cnt=[-1]*n tmp=0 R=-1 for L in range(n): while tmp<m and R<n-1: R+=1 tmp+=t[R] if tmp==m: cnt[L]=R+1 tmp-=t[L] return cnt A=f(a) B=f(b) C=f(c) ans=0 for i in range(n): if A[i]!=-1: if A[i]<n and B[A[i]]!=-1: if B[A[i]]<n and C[B[A[i]]]!=-1: ans+=1 print(ans)