#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 10, MAX = 2e5 + 1e4, MOD = 1e9 + 7;
void OUT(long double o, int x) {
  cout << fixed << setprecision(x) << o;
  return;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long x = 0, z = 0;
  for (int i = 4; i < s.size(); i++) {
    string q = "";
    for (int j = i - 4; j <= i; j++) q += s[j];
    if (q == "heavy") z++;
    q = "";
    for (int j = i; j < i + 5 && j < s.size(); j++) q += s[j];
    long long y = 0;
    if (q == "metal") y = 1;
    x += z * y;
  }
  cout << x;
  return 0;
}
