#include <bits/stdc++.h>
using namespace std;
int main() {
  int len, i;
  int pos = 0, pos1;
  long long sum = 0;
  int s = 0;
  int heavy[200000] = {0};
  int metal[1000000] = {0};
  char str[1000001];
  scanf("%s", str);
  len = strlen(str);
  for (i = 0; i < len; i++) {
    if (str[i] == 'h' && str[i + 1] == 'e' && str[i + 2] == 'a' &&
        str[i + 3] == 'v' && str[i + 4] == 'y') {
      heavy[pos++] = i;
    }
    {
      if (str[i] == 'm' && str[i + 1] == 'e' && str[i + 2] == 't' &&
          str[i + 3] == 'a' && str[i + 4] == 'l') {
        s++;
        metal[i] = s;
      } else {
        metal[i] = s;
      }
    }
  }
  for (i = 0; i < pos; i++) {
    pos1 = heavy[i];
    sum += s - metal[pos1];
  }
  cout << sum;
}
