#include <bits/stdc++.h>
using namespace std;
int main() {
  char s[1 << 20];
  int64_t r = 0;
  int i = -1, h = 0;
  cin >> s;
  while (s[++i])
    if (s[i] == 'h' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'v' &&
        s[i + 4] == 'y')
      h++, i += 4;
    else if (s[i] == 'm' && s[i + 1] == 'e' && s[i + 2] == 't' &&
             s[i + 3] == 'a' && s[i + 4] == 'l')
      r += (int64_t)h, i += 4;
  cout << r << endl;
  return 0;
}
