#include #define For(i, a, b) for(long long i = a; i < b; i++) #define rep(i, n) For(i, 0, n) #define rFor(i, a, b) for(long long i = a; i >= b; i--) #define ALL(v) (v).begin(), (v).end() #define rALL(v) (v).rbegin(), (v).rend() using namespace std; using lint = long long; using ld = long double; int main() { vector c(26); set st = {'h', 'e', 'w', 'r', 'd'}; rep(i, 26) { cin >> c[i]; } auto choose = [&](lint x) -> lint { return x * (x - 1LL) / 2LL; }; auto mxl = [&](lint x) -> lint { lint res = 0; for (lint i = 2; (x - i) >= 1; i++) { res = max(res, choose(i) * (x - i)); } return res; }; auto mxo = [&](lint x) -> lint { lint res = 0; for (lint i = 1; i < x; i++) { res = max(res, i * (x - i)); } return res; }; lint ans = 1; for (char ch : st) { ans *= c[ch - 'a']; } ans *= mxl(c['l' - 'a']); ans *= mxo(c['o' - 'a']); cout << ans << endl; }