#include <bits/stdc++.h>
using namespace std;
const int N = 21;
string s;
long long heavy = 0, sol = 0;
int main() {
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    string temp = s.substr(i, 5);
    if (temp == "heavy") {
      heavy++;
      i += 4;
    } else if (temp == "metal") {
      sol += heavy;
      i += 4;
    }
  }
  printf("%I64d", sol);
  return 0;
}
