#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  set<int> h, m;
  set<int>::iterator it, itlow, itt;
  cin >> s;
  int posh = s.find("heavy"), posm = s.find("metal");
  while (posh != string::npos) {
    h.insert(posh);
    posh = s.find("heavy", posh + 1, 5);
  }
  while (posm != string::npos) {
    m.insert(posm);
    posm = s.find("metal", posm + 1, 5);
  }
  long long p = m.size(), cnt = 0, pos = 0;
  itlow = m.begin();
  for (it = h.begin(); it != h.end(); it++) {
    for (itt = itlow; itt != m.end(); itt++) {
      if (*itt > *it) {
        cnt += (p - pos);
        break;
      }
      pos++;
    }
    itlow = itt;
  }
  cout << cnt << "\n";
}
