#include <bits/stdc++.h>
using namespace std;
bool chk(string &s, string &temp, int i) {
  string x = s.substr(i, 5);
  return (x == temp);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> ws >> s;
  int n = s.size();
  vector<int> h, m(n);
  m[n - 1] = 0;
  string a = "heavy", b = "metal";
  for (int i = 0; i < n; ++i) {
    if (chk(s, a, i)) {
      h.push_back(i);
    }
  }
  for (int i = n - 2; i >= 0; --i) {
    m[i] = m[i + 1];
    if (chk(s, b, i)) {
      ++m[i];
    }
  }
  long long sum = 0;
  for (int i : h) {
    sum += m[i + 1];
  }
  cout << sum;
  return 0;
}
