h, e, l, o, w, r, d = 0, 0, 0, 0, 0, 0, 0 for i in range(26): s = chr(ord('a') + i) if s == 'h': h += int(input()) elif s == 'e': e += int(input()) elif s == 'l': l += int(input()) elif s == 'o': o += int(input()) elif s == 'w': w += int(input()) elif s == 'r': r += int(input()) elif s == 'd': d += int(input()) else: input() ans = h * e * w * r * d ans *= ((o + 1) // 2) * (o // 2) res = 0 for i in range(2, l): res = max(res, (i * (i - 1) // 2) * (l - i)) print(ans * res)