#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e6 + 10;
ll KMP[N];
ll sum1 = 0, z = 0;
void asd(ll* p, string s, string s1, ll a) {
  ll len = s.size(), len1 = s1.size(), i, j, k;
  j = 0, KMP[0] = KMP[1] = 0;
  for (i = 1; i < len1; i++) {
    while (j && s1[i] != s1[j]) j = KMP[j];
    if (s1[i] == s1[j]) j++;
    KMP[i + 1] = j;
  }
  j = 0;
  for (i = 0; i < len; i++) {
    while (j && s[i] != s1[j]) j = KMP[j];
    if (s[i] == s1[j]) j++;
    if (j == len1) {
      if (a == 1)
        z++;
      else
        sum1 += z - p[i];
      j = KMP[j];
    }
    p[i] = z;
  }
}
int main() {
  string s, s1, s2;
  s = "heavy", s1 = "metal";
  cin >> s2;
  ll* p = new ll[s2.size() + 10];
  asd(p, s2, s1, 1);
  asd(p, s2, s, 2);
  cout << sum1 << endl;
  return 0;
}
