#include <bits/stdc++.h>
int main() {
  char hmetal[1000010];
  int heavy[200001];
  int metal[200001];
  int lenh = 0;
  int lenm = 0;
  scanf("%s", hmetal);
  int lens = strlen(hmetal);
  long long substr = 0;
  for (int i = 0; i + 4 < lens; i++) {
    if (hmetal[i] == 'h' and hmetal[i + 1] == 'e' and hmetal[i + 2] == 'a' and
        hmetal[i + 3] == 'v' and hmetal[i + 4] == 'y') {
      heavy[lenh] = i;
      lenh++;
    } else if (hmetal[i] == 'm' and hmetal[i + 1] == 'e' and
               hmetal[i + 2] == 't' and hmetal[i + 3] == 'a' and
               hmetal[i + 4] == 'l') {
      metal[lenm] = i;
      lenm++;
    }
  }
  int p = 0;
  for (int i = 0; i < lenh and p < lenm; i++) {
    while (heavy[i] > metal[p] and p < lenm) {
      p++;
    }
    if (p < lenm) {
      substr += lenm - p;
    }
  }
  printf("%I64d", substr);
  return 0;
}
