#include <bits/stdc++.h>
using namespace std;
char s[1000010];
int ss[1000010];
int main() {
  int u = 0, v = 4, k = 0, l = 0, r = 0;
  int c = 0, d = 0;
  long long sum = 0;
  char s1[] = {"heavy"};
  char s2[] = {"metal"};
  scanf("%s", s);
  int p = strlen(s);
  while (v <= p - 1) {
    for (int i = u, j = 0; i <= v; i++, j++) {
      if (s[i] != s1[j]) c = 1;
    }
    for (int i = u, j = 0; i <= v; i++, j++) {
      if (s[i] != s2[j]) d = 1;
    }
    if (c == 0) {
      ss[k] = 1;
      k++;
      l++;
    }
    if (d == 0) {
      k++;
      r++;
    }
    c = 0;
    d = 0;
    u++;
    v++;
  }
  for (int i = 0; i < k; i++) {
    if (ss[i] == 1) {
      sum += r;
    } else
      r--;
  }
  printf("%lld\n", sum);
  return 0;
}
