#include <bits/stdc++.h>
using namespace std;
char ch[1000005];
int main() {
  string s = "heavy", ss = "metal", a, b;
  long long i, j, k, l, m, n, ans = 0, h, count;
  gets(ch);
  l = strlen(ch);
  h = 0, m = 0, count = 0;
  for (i = 0; i < l; i++) {
    a = "";
    b = "";
    for (j = i; j < i + 5; j++) a += ch[j];
    if (a == s) h++;
    for (j = i; j < i + 5; j++) b += ch[j];
    if (b == ss) {
      count += h;
    }
  }
  printf("%I64d\n", count);
  return 0;
}
