from itertools import groupby from collections import defaultdict from heapq import * *a, = map(int,input().split()) d = defaultdict(list) t = input() for k,v in groupby(t): d[k].append(len(list(v))) def get(ai,lst): if not lst: return 1 res = 1 v = ai - sum(lst) if v < 0: return 0 lst = sorted(lst,reverse=True)[:65] q = [(-(i+1.0),i,i) for i in lst] # 倍率、先頭、長さ if len(q) == 1: c = lst[0] for i in range(min(c,ai-c)): res *= ai-i res //= i+1 if res >= MAX: return MAX return res if len(q) == 2 == sum(lst): return min(ai//2*((ai+1)//2),MAX) heapify(q) for _ in range(v): __,x,y = heappop(q) res = res*(y+1)//(y-x+1) heappush(q,(-(y+2)/(y+2-x),x,y+1)) if res >= MAX: return res return res ans = 1 MAX = 1<<62 for i,ai in enumerate(a): ans *= get(ai,d[chr(i+97)]) print(ans if ans < MAX else "hel")