#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long sum1 = 0;
  long long sum2 = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s.substr(i, 5) == "heavy")
      sum2++;
    else if (s.substr(i, 5) == "metal")
      sum1 = sum1 + sum2;
  }
  cout << sum1 << endl;
  return 0;
}
