#include #include #include #include using namespace std; int main() { map cnt; for (char c = 'a'; c <= 'z'; c++) cin >> cnt[c]; long long ans = 1; for (char c: "hewrd") if (c) ans *= cnt[c]; int ma_l = 0; for (int i = 2; i < cnt['l']; i++) { int tmp = (i * (i - 1) / 2) * (cnt['l'] - i); ma_l = max(ma_l, tmp); } int ma_o = 0; for (int i = 1; i < cnt['o']; i++) { int tmp = i * (cnt['o'] - i); ma_o = max(ma_o, tmp); } cout << ans * ma_l * ma_o << endl; return 0; }