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