#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<int> a, b;
  if (s.length() < 5) {
    cout << "0";
    return 0;
  }
  for (int i = 0; i < s.length() - 4; i++) {
    if (s[i] == 'h') {
      if (s.substr(i, 5) == "heavy") a.push_back(i);
    }
  }
  for (int i = 0; i < s.length() - 4; i++) {
    if (s[i] == 'm') {
      if (s.substr(i, 5) == "metal") b.push_back(i);
    }
  }
  int ind = 0;
  long long int cnt = 0;
  for (int i = 0; i < a.size(); i++) {
    if (b.size() == 0) break;
    if (a[i] < b[ind]) {
      cnt += b.size() - ind;
    } else {
      while (b[ind] < a[i] && ind < b.size()) ind++;
      if (ind != b.size()) cnt += b.size() - ind;
    }
  }
  cout << cnt;
  return 0;
}
