import sys C = {} h = "helloworld" for i in range(27): tmp = input() if chr(i+97) in set(h): C[chr(i+97)] = int(tmp) total = C["h"] for i in set(h)-set("h"): if i != "l" and i != "o": total *= C[i] elif i == "o": total *= C[i]//2 total *= C[i]-C[i]//2 else: total *= max([(j*(j-1)//2) * (C[i]-j) for j in range(C[i],0,-1)]) print(i,total) print(total)