package yukicoder; import java.util.Scanner; public class Q073 { public static void main(String[] args)throws Exception{ new Q073().solve(); } void solve(){ Scanner sc=new Scanner(System.in); String s="abcdefghijklmnopqrstuvwxyz"; long h=0,e=0,l=0,o=0,w=0,r=0,d=0; for(int i=0;i<26;i++){ int a=sc.nextInt(); if(i==7)h=a; else if(i==s.indexOf("e"))e=a; else if(i==s.indexOf("l"))l=a; else if(i==s.indexOf("o"))o=a; else if(i==s.indexOf("w"))w=a; else if(i==s.indexOf("r"))r=a; else if(i==s.indexOf("l"))l=a; else if(i==s.indexOf("d"))d=a; } // System.out.println(h+" "+e+" "+l+" "+o+" "+w+" "+r+" "+d); long x=(long)((l+1+Math.sqrt(l*l-l+1))/3.0); long o1=o/2;long o2=o-o1;o=0; long ans=Math.max(h*e*w*r*(l-x)*d*o1*o2*x*(x-1)/2, h*e*w*r*(l-x-1)*d*o1*o2*(x+1)*x/2); System.out.println(ans); // System.out.println(s.indexOf("h")); // System.out.println(s.indexOf("e")); // System.out.println(s.indexOf("l")); // System.out.println(s.indexOf("o")); // System.out.println(s.indexOf("w")); // System.out.println(s.indexOf("r")); // System.out.println(s.indexOf("d")); } }