#define _USE_MATH_DEFINES #include using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; long long ans = 0; string t; int n = (int) s.size(); for (int i = 0; i < n; i++) { if (s.substr(i, 5) == "phnom") { t += "penh"; i += 4; ans++; } else { t += s[i]; } } s = t; //cerr << s << endl; n = (int) s.size(); bool found = false; t = ""; for (int i = 0; i < n; i++) { if (s[i] == 'e' || s[i] == 'h') { found = true; } if (s[i] == 'e') t += 'h'; else if (s[i] != 'h') t += s[i]; } s = t; //cerr << s << endl; if (found) ans++; n = (int) s.size(); int cnt = 0; int phn = false; vector v; for (int i = 0; i < n; i++) { if (s.substr(i, 3) == "phn") { cnt = 0; phn = true; i += 2; continue; } if (s.substr(i, 2) == "om" && phn) { cnt++; i += 1; } else { if (cnt > 0) v.push_back(cnt); phn = false; cnt = 0; } } if (cnt > 0) v.push_back(cnt); // for (int i : v) cerr << i << " "; // cerr << endl; // cerr << ans << endl; if (v.empty()) { int mx = 0; for (int i = 0; i < n; i++) { if (s[i] == 'e') mx = max(2, mx); if (s[i] == 'h') mx = max(1, mx); } ans += mx; } else { int mx = 0; for (int i : v) { ans += i; mx = max(i, mx); } ans += mx + 1; } cout << ans << endl; return 0; }