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