#include <bits/stdc++.h>
using namespace std;
int binary_search(int *arr, int n, int x) {
  int l = 0, r = n - 1, mid, ans = n;
  while (l <= r) {
    mid = (l + r) / 2;
    if (arr[mid] > x) {
      r = mid - 1;
      ans = mid;
    } else
      l = mid + 1;
  }
  return ans;
}
int main() {
  string s;
  cin >> s;
  int heavy[1000000] = {0}, metal[1000000] = {0}, m = 0, n = 0;
  for (int i = 0; i < s.length(); i++) {
    string temp = "";
    if (i + 5 <= s.length()) temp = s.substr(i, 5);
    if (temp == "heavy")
      heavy[m++] = i;
    else if (temp == "metal")
      metal[n++] = i;
  }
  long long count = 0;
  for (int i = 0; i < m; i++) {
    int j = binary_search(metal, n, heavy[i]);
    count += (n - j);
  }
  cout << count;
  return 0;
}
