#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int INF = 1e18;
const long long int MAX_N = 1e6 + 4;
void solve() {
  string s;
  cin >> s;
  int n = s.size();
  string hs = "heavy";
  string ms = "metal";
  int h = 0;
  long long int ans = 0;
  for (int i = 0; i + 4 < n;) {
    if (s.substr(i, 5) == hs)
      h++, i += 5;
    else if (s.substr(i, 5) == ms)
      ans += h, i += 5;
    else
      i++;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  cerr << endl
       << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}
