#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, s1 = "";
  cin >> s;
  long long i = 0, j = s.length() - 1, c = 0, d = 0;
  for (; i < s.length(); ++i) {
    if (s[i] == 'h') {
      s1 = s.substr(i, 5);
      if (s1 == "heavy") {
        while (j > i) {
          if (j <= s.length() - 5 && s[j] == 'm') {
            s1 = s.substr(j, 5);
            if (s1 == "metal") {
              c++;
            }
          }
          if (c != 0 && s[j] == 'h') {
            s1 = s.substr(j, 5);
            if (s1 == "heavy") {
              d += c;
            }
          }
          j--;
        }
        break;
      }
    }
  }
  cout << (long long)c + d;
}
