#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int inf = 2000000000;
int arrh[1000005];
int arrm[1000005];
char strh[] = "heavy";
char strm[] = "metal";
int main() {
  char str[1000005];
  scanf("%s", str);
  int l = strlen(str);
  int h = 0, m = 0;
  int pos = 0;
  long long ans = 0;
  while (1) {
    if (pos >= l) break;
    int pos1 = pos;
    if (str[pos] == 'h') {
      pos++;
      bool ok = 1;
      int posh = 1;
      while (1) {
        if (posh >= 5) break;
        if (str[pos] == strh[posh]) {
          pos++;
          posh++;
        } else {
          ok = 0;
          break;
        }
      }
      if (ok == 1) {
        arrh[h] = pos1;
        h++;
        pos = pos1 + 5;
      } else {
        pos = pos1 + 1;
      }
    } else {
      pos = pos1 + 1;
    }
  }
  pos = 0;
  while (1) {
    if (pos >= l) break;
    int pos1 = pos;
    if (str[pos] == 'm') {
      pos++;
      bool ok = 1;
      int posm = 1;
      while (1) {
        if (posm >= 5) break;
        if (str[pos] == strm[posm]) {
          pos++;
          posm++;
        } else {
          ok = 0;
          break;
        }
      }
      if (ok == 1) {
        arrm[m] = pos1;
        m++;
        pos = pos1 + 5;
      } else {
        pos = pos1 + 1;
      }
    } else {
      pos = pos1 + 1;
    }
  }
  int i, j;
  for (i = 0; i < h; i++) {
    int lo = 0;
    int hi = m;
    int mid;
    while (lo < hi) {
      mid = lo + (hi - lo) / 2;
      if (arrm[mid] > arrh[i]) {
        hi = mid;
      } else
        lo = mid + 1;
    }
    int midans = m - lo;
    ans += midans;
  }
  printf("%I64d\n", ans);
  return 0;
}
