#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  ;
  cin.tie(NULL);
  ;
  string s, s1, s2, s3;
  cin >> s;
  s1 = "heavy";
  s2 = "metal";
  int n, i;
  long long an = 0, h1 = 0, h2 = 0;
  n = s.length();
  for (i = 0; i < n - 4; i++) {
    s3 = s.substr(i, 5);
    if (s3 == s1) h1++;
    if (s3 == s2) {
      an += h1;
    }
  }
  cout << an;
  cout << "\n";
}
