# Read input counts = [int(input()) for _ in range(26)] # Extract the required counts h = counts[7] e = counts[4] l_count = counts[11] o = counts[14] w = counts[22] r = counts[17] d = counts[3] # Check if the required characters are present in sufficient amounts if h < 1 or e < 1 or l_count < 3 or o < 2 or w < 1 or r < 1 or d < 1: print(0) else: # Calculate maximum contribution from 'l' max_l = 0 for x in range(2, l_count): # remaining l's = l_count - x current = (x * (x - 1) * (l_count - x)) // 2 if current > max_l: max_l = current # Calculate maximum contribution from 'o' o_contrib = (o // 2) * ((o + 1) // 2) # Compute the result result = h * e * max_l * o_contrib * w * r * d print(result)