#include <bits/stdc++.h>
using namespace std;
string str;
int main() {
  cin >> str;
  vector<int> heavy, metal;
  for (int i = 0; i < max((int)(str.size() - 4), 0); i++) {
    string str1 = str.substr(i, 5);
    if (str1 == "heavy") heavy.push_back(i);
    if (str1 == "metal") metal.push_back(i);
  }
  long long a = 0;
  for (int i = 0, j = 0; i < heavy.size() && j < metal.size();) {
    if (heavy[i] < metal[j]) {
      a += metal.size() - j;
      i++;
    } else
      j++;
  }
  cout << a;
  return 0;
}
