#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(0);
  string seq;
  cin >> seq;
  vector<int> sfx(seq.size());
  for (int i = 0; i + 5 <= seq.size(); ++i) {
    sfx[i] = seq.substr(i, 5) == "metal";
  }
  for (int i = seq.size() - 1; i - 1 >= 0; --i) {
    sfx[i - 1] += sfx[i];
  }
  long long ans = 0LL;
  for (int i = 0; i < seq.size(); ++i) {
    if (seq.substr(i, 5) == "heavy") {
      ans += sfx[i];
    }
  }
  cout << ans << endl;
  return 0;
}
