import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines *C, = map(int,read().split()) h,e,l,l,o,w,o,r,l,d = [C[ord(x) - ord('a')] for x in 'helloworld'] x = h * e * w * r * d x *= max(x * (l-x) * (l-x-1) // 2 for x in range(l+1)) x *= max(x * (o-x) for x in range(o+1)) print(x)