package yukicoder; import java.util.Scanner; public class Main{ public static void main(String[] args)throws Exception{ new Main().solve(); } void solve(){ Scanner sc=new Scanner(System.in); String s="abcdefghijklmnopqrstuvwxyz"; int 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); int x=(int)((l+1+Math.sqrt(l*l-l+1))/3.0); int o1=o/2;int 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")); } //階乗 long fact(int n){ long ans=1; for(int i=1;i<=n;i++)ans*=i; return ans; } //1~nの数字からk個取る方法の数 long nCk(int n,int k){ if(n