#include using namespace std; int main(){ string S; cin >> S; int64_t ans = 0; for(int t=0; t<10; t++){ int N = S.size(); int pt = 0; string T, U; while(pt < N){ if(S.substr(pt, 5) == "phnom"){ T.append("penh"); pt += 5; ans++; }else{ T.push_back(S[pt]); pt++; } } bool found = false; for(char c : T){ if(c == 'h'){ found = true; }else if(c == 'e'){ found = true; U.push_back('h'); }else{ U.push_back(c); } } if(found) ans++; S = U; } int mx = 0; int pt = 0, N = S.size(); while(pt < N){ bool found = false; if(S.substr(pt, 5) == "phnom"){ found = true; ans++; pt += 5; }else if(S.substr(pt, 4) == "penh"){ found = true; pt += 4; } if(found){ int num = 0; while(S.substr(pt, 2) == "om"){ num++; ans++; } mx = max(mx, num+2); }else{ if(S[pt] == 'h') mx = max(mx, 1); if(S[pt] == 'e') mx = max(mx, 2); pt++; } } ans += mx; cout << ans << endl; return 0; }