#include <bits/stdc++.h>
using namespace std;
char s[1000005];
int main() {
  long long int i, j, k = 1, l, m, n, c = 0, h = 0, ans = 0;
  gets(s);
  l = strlen(s);
  for (i = 0; i < l;) {
    if (!strncmp(s + i, "heavy", 5)) {
      h++;
      i += 5;
    } else if (!strncmp(s + i, "metal", 5)) {
      ans += h;
      i += 5;
    } else
      i++;
  }
  cout << ans;
}
