#include using namespace std; typedef long long ll; signed main(){ vector< int > cnt( 256 ); for( int i = 'a'; i <= 'z'; ++i ) cin >> cnt[ i ]; if( cnt[ 'h' ] < 1 or cnt[ 'e' ] < 1 or cnt[ 'l' ] < 3 or cnt[ 'o' ] < 2 or cnt[ 'w' ] < 1 or cnt[ 'r' ] < 1 or cnt[ 'd' ] < 1 ) cout << 0 << endl, exit( 0 ); ll ans = 1; ans *= cnt[ 'h' ]; ans *= cnt[ 'e' ]; ans *= cnt[ 'w' ]; ans *= cnt[ 'r' ]; ans *= cnt[ 'd' ]; ll x = 0; for( int i = 2; cnt[ 'l' ] - i >= 1; ++i ){ x = max( x, 1LL * ( cnt[ 'l' ] - i ) * i * ( i - 1 ) / 2 ); } ans *= x; x = 0; for( int i = 1; cnt[ 'o' ] - i >= 1; ++i ){ x = max( x, 1LL * ( cnt[ 'o' ] - i ) * i / 2 ); } ans *= x; cout << ans << endl; return 0; }