import collections import itertools N = int(input()) A,B,C = map(int,input().split()) SS = input().split() L = [0] for s in SS: L.append(len(s)) AC = list(itertools.accumulate(L)) d = collections.defaultdict(int) for ac in AC: d[ac]=1 ans = 0 for ac in AC: if d[ac+A]==1 and d[ac+A+B]==1 and d[ac+A+B+C]==1: ans+=1 print(ans)