#include using namespace std; typedef long long ll; #define REP(i, n) for(int(i)=0;(i)<(n);++(i)) #define REPEAT(i, k, n) for(int(i)=(k);(i)<((k)+(n));++(i)) int C[27],U[27]; int comb(int n, int m){ int k = 1; for(int i = 0; i < m; i++){ k *= (n-i); } for(int i = 2; i <= m; i++){ k /= i; } return k; } int main(){ const string s = "helloworld"; REP(i,27){ cin >> C[i]; } REP(i,(int)s.size()){ int c = s[i]-'a'; U[c]++; if(C[c]-U[c] < 0){ cout << 0 << endl; return 0; } } ll k = 1; REP(i,27){ if(!U[i]) continue; if(i == ('l'-'a')){ } else if(i == ('o'-'a')){ } else { k *= C[i]; } } ll maxv = 0; int i = 'l'-'a'; REP(j,C[i]-U[i]+1){ maxv = max(maxv, k*comb(j+2,2)*(C[i]-U[i]-j+1)); } k = maxv; i = 'o'-'a'; REP(j,C[i]-U[i]+1){ maxv = max(maxv, k*(j+1)*(C[i]-U[i]-j+1)); } cout << maxv << endl; return 0; }