#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
char s[maxn + 100], *s1 = "heavy", *s2 = "metal";
int main() {
  long long h1 = 0, sum = 0;
  scanf("%s", s);
  int len = strlen(s);
  for (int i = 0; i < len - 4; i++) {
    int t1 = 0, t2 = 0;
    for (int j = 0; j < 5; j++) {
      if (s[i + j] == s1[j]) t1++;
      if (s[i + j] == s2[j]) t2++;
    }
    if (t1 == 5) h1++;
    if (t2 == 5) sum += h1;
  }
  cout << sum << endl;
  return 0;
}
