#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  vector<long long int> x, y;
  cin >> a;
  long long int n = a.size();
  for (long long int i = 0; i < n - 4; i++) {
    if (a[i] == 'h' && a[i + 1] == 'e' && a[i + 2] == 'a' && a[i + 3] == 'v' &&
        a[i + 4] == 'y')
      x.push_back(i);
    else if (a[i] == 'm' && a[i + 1] == 'e' && a[i + 2] == 't' &&
             a[i + 3] == 'a' && a[i + 4] == 'l')
      y.push_back(i);
  }
  sort(x.begin(), x.end());
  long long int cnt = 0;
  for (long long int i = 0; i < y.size(); i++) {
    cnt += (lower_bound(x.begin(), x.end(), y[i]) - x.begin());
  }
  cout << cnt;
}
