#include <bits/stdc++.h>
using namespace std;
int main() {
  int index, i, k;
  int arr[1000010];
  int metal[1000010];
  string str;
  cin >> str;
  index = str.find("heavy");
  i = 0;
  while (index != -1) {
    arr[i++] = index;
    index = str.find("heavy", index + 1);
  }
  k = 0;
  index = str.find("metal");
  while (index != -1) {
    metal[k++] = index;
    index = str.find("metal", index + 1);
  }
  sort(arr, arr + i);
  sort(metal, metal + k);
  long long sum = 0LL;
  for (int x = 0; x < i; x++) {
    int* location = upper_bound(metal, metal + k, arr[x]);
    int ind = location - metal;
    sum += (k - ind);
  }
  cout << sum << endl;
  return 0;
}
