#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.length();
  long long int heavy = 0, ans = 0;
  for (int i = 0; i <= n - 5; i++) {
    string t = s.substr(i, 5);
    if (t == "heavy") heavy++;
    if (t == "metal") ans += heavy;
  }
  cout << ans;
  return 0;
}
