#include <bits/stdc++.h>
using namespace std;
char s[1000100], h[] = "heavy", m[] = "metal";
int main() {
  scanf(" %s", s);
  int len = strlen(s);
  bool f;
  long long ans = 0;
  int c = 0;
  for (int i = 0; i < len - 4; i++) {
    f = true;
    for (int j = 0; j < 5; j++)
      if (s[i + j] != h[j]) f = false;
    if (f) c++;
    f = true;
    for (int j = 0; j < 5; j++)
      if (s[i + j] != m[j]) f = false;
    if (f) ans += c;
  }
  cout << ans << endl;
  return 0;
}
