#include <bits/stdc++.h>
using namespace std;
char str[2100000];
const char id1[] = "heavy";
const char id2[] = "metal";
int main() {
  scanf("%s", str);
  int len = strlen(str);
  long long cntofh = 0;
  long long cntofm = 0;
  long long ans = 0;
  int i, j;
  bool judge;
  for (i = 0; i < len; i++) {
    if (str[i] == 'h') {
      judge = true;
      for (j = 0; j < 5 && i + j < len; j++) {
        if (str[i + j] != id1[j]) {
          judge = false;
          break;
        }
      }
      if (j != 5) judge = false;
      if (judge) cntofh++;
    } else if (str[i] == 'm') {
      judge = true;
      for (j = 0; j < 5 && i + j < len; j++) {
        if (str[i + j] != id2[j]) {
          judge = false;
          break;
        }
      }
      if (j != 5) judge = false;
      if (judge) {
        cntofm++;
        ans += (cntofh);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
