D = [0] * 26 for i in range(26): D[i] = int(input()) ans = 1 L = D[ord("l") - ord("a")] O = D[ord("o") - ord("a")] vL = -1 vO = -1 for i in range(L + 1): vL = max(vL, i * (i - 1)//2 * (L - i)) for i in range(O + 1): vO = max(vO, i * (O - i)) ans = vL * vO for s in ["h", "e", "w", "r", "d"]: ans *= D[ord(s) - ord("a")] print(ans)