#include <bits/stdc++.h>
using namespace std;
bool is_heavy(string& s, int ind) {
  return s[ind + 3] == 'v' && s[ind] == 'h' && s[ind + 1] == 'e' &&
         s[ind + 2] == 'a' && s[ind + 4] == 'y';
}
bool is_metal(string& s, int ind) {
  return s[ind + 2] == 't' && s[ind] == 'm' && s[ind + 1] == 'e' &&
         s[ind + 3] == 'a' && s[ind + 4] == 'l';
}
int main() {
  string s;
  s.reserve(1000000);
  int ch;
  while ((ch = getchar()) != '\n' && ch != EOF) {
    s.push_back(ch);
  }
  vector<int> h, m;
  h.reserve(s.size() / 5);
  m.reserve(s.size() / 5);
  for (int i = 0; i < (int)s.size() - 4; ++i) {
    if (is_heavy(s, i)) {
      h.push_back(i);
      i += 4;
    } else if (is_metal(s, i)) {
      m.push_back(i);
      i += 4;
    }
  }
  long long res = 0;
  int hi = 0, mi = 0;
  for (int i = 0; i < h.size() && mi < m.size(); ++i) {
    while (mi < m.size() && m[mi] <= h[i]) {
      ++mi;
    }
    res += m.size() - mi;
  }
  cout << res << endl;
  return 0;
}
