#include <bits/stdc++.h>
using namespace std;
const int L = 1e6;
char t[L + 1];
bool f[L], g[L];
int sumg[L + 1];
int main() {
  scanf(" %s", t);
  int len = strlen(t);
  for (int i = 0; i < len; i++) {
    if (strncmp("heavy", t + i, 5) == 0) f[i] = true;
  }
  for (int i = 0; i < len; i++) {
    if (strncmp("metal", t + i, 5) == 0) g[i] = true;
  }
  for (int i = len - 1; i >= 0; i--) {
    sumg[i] = sumg[i + 1];
    if (g[i]) sumg[i]++;
  }
  long long ret = 0;
  for (int i = 0; i < len; i++) {
    if (f[i]) ret += sumg[i];
  }
  cout << ret << endl;
  return 0;
}
