#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  long long h, m, ans;
  cin >> s;
  int n = s.length();
  string s1, s2, r1, r2;
  s1 = "heavy";
  s2 = "metal";
  r1 = "heavy";
  r2 = "metal";
  h = 0;
  m = 0;
  ans = 0;
  for (int i = 0; i < n; i++) {
    if ((s[i] == 'h') && (i + 5 <= n)) {
      for (int j = 0; j < 5; j++) {
        r1[j] = s[i + j];
      }
      if (r1 == s1) h++;
    }
    if ((s[i] == 'm') && (i + 5 <= n)) {
      for (int j = 0; j < 5; j++) {
        r2[j] = s[i + j];
      }
      if (r2 == s2) {
        ans += h;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
