#include int ri() { int n; scanf("%d", &n); return n; } int64_t rs64() { int64_t n; scanf("%" SCNd64, &n); return n; } int solve(const std::string &s) { int n = s.size(); std::vector all; for (int i = 0; i + 4 < n; i++) { if (s.substr(i, 5) == "phnom") { all.push_back(0); i += 5; while (i + 1 < n && s[i] == 'o' && s[i + 1] == 'm') i += 2, all.back()++; i--; } } if (all.size()) return std::accumulate(all.begin(), all.end(), 0) + *std::max_element(all.begin(), all.end()) + all.size() + 2; else if (std::count(s.begin(), s.end(), 'e')) return 2; else if (std::count(s.begin(), s.end(), 'h')) return 1; else return 0; } int main() { std::string s; std::cin >> s; int n = s.size(); int res = solve(s); std::string t; for (auto c : s) if (c != 'h') t.push_back(c); std::replace(t.begin(), t.end(), 'e', 'h'); res = std::max(res, solve(t) + 1); printf("%d\n", res); return 0; }