#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)); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s; cin >> s; ll con = 0; ll ans = 0; REP(j, 2) { con = 0; string t; REP(i, s.size()) { if (s[i] == 'h') continue; if (s[i] == 'e') t += "h"; else t += s.substr(i, 1); //1の操作をできるだけ if (i + 5 > s.size()) continue; if (s.substr(i, 5) == "phnom") { con++; t += "hn"; i += 4; } } if (s == t) { cout << ans << en; return 0; } else { ans++; ans += con; } s = t; t = ""; cout << s << en; cout << ans << en; } if (con == 0) { cout << ans << en; return 0; } else { con = 0; } bool flag = false; REP(i, s.size()-1) { if (flag) { if (s.substr(i, 2) == "om") { con++; i += 1; } else { flag = false; } } if (!flag) { if (i + 5 > s.size()) break; if (s.substr(i, 5) == "phnom") { con ++; i += 4; flag = true; } } } ans += con * 2 + 1; cout << ans << en; return 0; }