#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
  if (b > a) return gcd(b, a);
  return b == 0 ? a : gcd(b, a % b);
}
int main() {
  char s[1000001];
  scanf("%s", s);
  long long int i, count = 0, ans = 0;
  for (i = 0; i < strlen(s); i++) {
    if (strncmp(s + i, "heavy", 5) == 0) {
      count++;
    }
    if (strncmp(s + i, "metal", 5) == 0) {
      ans += count;
    }
  }
  cout << ans << endl;
  return 0;
}
