#include <bits/stdc++.h>
using namespace std;
const double PI = 2 * acos(0.0);
const int Mod = 1E9 + 7;
long long binpow(long long a, long long b, long long m = Mod) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
inline void yes() { std::cout << "Yes\n"; }
inline void no() { std::cout << "No\n"; }
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string a;
  cin >> a;
  string h = "heavy";
  string back = "metal";
  long long int l = a.length();
  vector<long long int> hpos;
  vector<long long int> mpos;
  for (long long int i = (0); i < (l); i++) {
    if (a.substr(i, 5) == h) hpos.push_back(i), i = i + 4;
    if (a.substr(i, 5) == back) mpos.push_back(i), i = i + 4;
  }
  long long int total = 0;
  for (auto i : hpos) {
    long long int count =
        upper_bound(mpos.begin(), mpos.end(), i) - mpos.begin();
    total = total + mpos.size() - count;
  }
  cout << total << '\n';
}
