#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const long long int mymax = 1e18;
const long long int mymin = -1e18;
const double PIE = 3.1415926536;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s, a = "heavy", b = "metal";
  cin >> s;
  long int slen = s.length();
  long long int ans = 0;
  if (slen < 10) {
    cout << 0;
    return 0;
  }
  vector<long int> h, m;
  int tmp;
  bool valid;
  for (long int i = 0; i < slen - 4; i++) {
    if (s[i] == 'h') {
      tmp = 1;
      valid = true;
      i++;
      while (i < slen && tmp < 5) {
        if (s[i] != a[tmp]) {
          valid = false;
          break;
        }
        tmp++;
        i++;
      }
      if (valid) {
        h.push_back(i - 5);
      }
      i--;
    } else if (s[i] == 'm') {
      tmp = 1;
      valid = true;
      i++;
      while (i < slen && tmp < 5) {
        if (s[i] != b[tmp]) {
          valid = false;
          break;
        }
        tmp++;
        i++;
      }
      if (valid) {
        m.push_back(i - 5);
      }
      i--;
    }
  }
  if (h.empty() || m.empty()) {
    cout << 0;
    return 0;
  }
  long int msz = m.size();
  for (auto ht = h.begin(); ht != h.end(); ht++) {
    ans += (long long int)(msz -
                           (lower_bound(m.begin(), m.end(), *ht) - m.begin()));
  }
  cout << ans;
  return 0;
}
