#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long int N = s.length();
  string a = "heavy";
  string b = "metal";
  vector<int> hea;
  vector<int> me;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'h') {
      string init = "";
      if (i + 4 < N) {
        for (int j = i; j <= i + 4; j++) {
          init = init + s[j];
        }
      }
      if (init == a) {
        hea.push_back(i);
      }
    }
  }
  for (int i = 0; i < N; i++) {
    if (s[i] == 'm') {
      string init = "";
      if (i + 4 < N) {
        for (int j = i; j <= i + 4; j++) {
          init = init + s[j];
        }
        if (init == b) {
          me.push_back(i);
        }
      }
    }
  }
  long long int ans = 0;
  for (int i = 0; i < hea.size(); i++) {
    long long int j = lower_bound(me.begin(), me.end(), hea[i]) - me.begin();
    if (j < me.size()) {
      ans = ans + (me.size() - j);
    }
  }
  cout << ans << endl;
}
