#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,n) for(ll (i)=0;(i)<(n);(i)++) #define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++) #define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i) #define ll long long #define ull unsigned long long #define all(hoge) (hoge).begin(),(hoge).end() #define en '\n' typedef pair P; const long long INF = 1LL << 60; const long long MOD = 1e9 + 7; typedef vector Array; typedef vector Matrix; const int loose = 0; const int tight = 1; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } //グラフ関連 struct Edge {//グラフ ll to, cap, rev; Edge(ll _to, ll _cap, ll _rev) { to = _to; cap = _cap; rev = _rev; } }; typedef vector Edges; typedef vector Graph; void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) { G[from].push_back(Edge(to, cap, (ll)G[to].size())); if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1)); } ll mod_pow(ll x, ll n, ll mod) { ll res = 1LL; while (n > 0) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } ll mod_inv(ll x, ll mod) { return mod_pow(x, mod - 2, mod); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s; cin >> s; ll n = s.size(); bool flag_phn = false; bool flag_o = false; ll con = 0; ll con2 = 0; ll ans = 0; REP(i, n) { if (flag_phn) { if (con >= 1 && s[i] == 'h') continue; if (con >= 2 && s[i] == 'e') continue; if (flag_o) { if (s[i] == 'm') { con++; chmax(ans, 2 * con + 1); flag_o = false; if (con == 1) con2++; } else { con = 0; flag_o = false; flag_phn = false; } } else { if (s[i] == 'o') { flag_o = true; } else { con = 0; flag_phn = false; } } } if (!flag_phn) { if (i + 2 >= n) break; if (s.substr(i, 3) == "phn") { flag_phn = true; i += 2; } } } flag_phn = false; flag_o = false; con = 0; REP(i, n) { if (s[i] == 'h') continue; if (flag_phn) { if (con >= 1 && s[i] == 'e') continue; if (flag_o) { if (s[i] == 'm') { con++; chmax(ans, 2 * con + 2); flag_o = false; if (con == 1) con2++; } else { con = 0; flag_o = false; flag_phn = false; } } else { if (s[i] == 'o') { flag_o = true; } else { con = 0; flag_phn = false; } } } if (!flag_phn) { if (i + 2 >= n) break; if (s.substr(i, 3) == "pen") { flag_phn = true; i += 2; } else { if (i + 3 >= n) break; if (s.substr(i, 4) == "phen" || s.substr(i, 4) == "pehn") { flag_phn = true; i += 3; } else { if (i + 4 >= n) break; if (s.substr(i, 5) == "phehn") { flag_phn = true; i += 4; } } } } } chmax(ans, ans + con2 - 1); REP(i, n) { if (s[i] == 'h') { chmax(ans, 1LL); } if (s[i] == 'e') { chmax(ans, 2LL); break; } } cout << ans << endl; return 0; }