#include <bits/stdc++.h>
using namespace std;
vector<int> kmp(string s) {
  int n = s.length();
  vector<int> pi(n, 0);
  vector<int> ans;
  for (int i = 1; i < n; i++) {
    int j = pi[i - 1];
    while (j > 0 && s[i] != s[j]) j = pi[j - 1];
    if (s[i] == s[j]) pi[i] = j + 1;
    if (pi[i] == 5) ans.push_back(i);
  }
  return ans;
}
int main() {
  string s;
  cin >> s;
  string a, b;
  a = "heavy#" + s;
  b = "metal#" + s;
  vector<int> h = kmp(a);
  vector<int> m = kmp(b);
  long long res = 0;
  for (int i = 0; i < h.size(); i++) {
    int p = h[i];
    int k = upper_bound(m.begin(), m.end(), p) - m.begin();
    if (k != -1) res += (m.size() - k);
  }
  cout << res << endl;
  return 0;
}
