#include <bits/stdc++.h>
using namespace std;
long long cnt, ans, i, j, temp, flag;
string s, heavy = "heavy", metal = "metal";
int main() {
  cin >> s;
  for (i = 0; i < s.length(); i++) {
    temp = i;
    flag = 0;
    for (j = 0; j < 5; j++) {
      if (s[temp] == heavy[j])
        ++temp;
      else
        break;
    }
    if (j == 5) flag = 1, ++cnt;
    if (flag) {
      i = temp - 2;
      continue;
    }
    temp = i;
    for (j = 0; j < 5; j++) {
      if (s[temp] == metal[j])
        ++temp;
      else
        break;
    }
    if (j == 5) flag = 1, ans += cnt;
    if (flag) {
      i = temp - 2;
      continue;
    }
  }
  cout << ans;
}
