#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<int> a;
  string temp1 = "heavy";
  string temp2 = "metal";
  int pos = 0;
  int i = 0;
  while (i < s.length()) {
    if (s[i] == 'h') {
      pos = 0;
      while (pos < 5 && i < s.length() && s[i] == temp1[pos]) {
        ++i;
        ++pos;
      }
      if (pos == 5) a.push_back(1);
    } else if (s[i] == 'm') {
      pos = 0;
      while (pos < 5 && i < s.length() && s[i] == temp2[pos]) {
        ++i;
        ++pos;
      }
      if (pos == 5) a.push_back(-1);
    } else {
      ++i;
    }
  }
  unsigned long long rez = 0;
  int k_pos = 0;
  for (int i = 0; i < a.size(); ++i) {
    if (a[i] == 1) ++k_pos;
    if (a[i] == -1) rez += k_pos;
  }
  cout << rez;
  return 0;
}
