n = int(input()) a, b, c = map(int, input().split()) S = input().split() S = [len(s) for s in S] ans = 0 se = {0} tot = 0 for i in range(n): tot += S[i] se.add(tot) if tot - c in se and tot - c - b in se and tot - c - b - a in se: ans += 1 print(ans)