#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int k = 0, n, h = 0;
  string input;
  cin >> input;
  n = input.length();
  for (int i = 0; i < n; i++) {
    if (input.substr(i, 5) == "heavy") h++;
    if (input.substr(i, 5) == "metal") k += h;
  }
  cout << k << endl;
  return 0;
}
