#include <bits/stdc++.h>
using namespace std;
string t;
long long cnt1[3000001];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> t;
  cnt1[0] = 0;
  int n = (int)t.length();
  for (int i = 0; i <= n - 4; ++i) {
    if (t.substr(i, 5) == "heavy") ++cnt1[i + 1];
    cnt1[i + 1] += cnt1[i];
  }
  long long ans = 0;
  for (int i = 0; i <= n - 4; ++i)
    if (t.substr(i, 5) == "metal") ans += cnt1[i];
  cout << ans;
  return 0;
}
