#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 1;
string g;
deque<long long> v, vc;
long long cnt;
void DNM() {
  cin >> g;
  if (g.size() < 5) {
    cout << 0;
    return;
  }
  for (long long i = 0; i < g.size() - 4; i++) {
    if (g[i] == 'h' and g[i + 1] == 'e' and g[i + 2] == 'a' and
        g[i + 3] == 'v' and g[i + 4] == 'y')
      v.push_back(i);
    else if (g[i] == 'm' and g[i + 1] == 'e' and g[i + 2] == 't' and
             g[i + 3] == 'a' and g[i + 4] == 'l')
      vc.push_back(i);
  }
  while (v.size() > 0 and vc.size() > 0) {
    if (vc[0] > v[0]) {
      cnt += vc.size();
      v.erase(v.begin());
    } else
      vc.erase(vc.begin());
  }
  cout << cnt << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int Qu_l_uQ = 1;
  while (Qu_l_uQ--) DNM();
}
