#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  unsigned long long int count = 0, output = 0;
  cin >> a;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == 'h' && a[i + 1] == 'e' && a[i + 2] == 'a' && a[i + 3] == 'v' &&
        a[i + 4] == 'y')
      count++;
    if (a[i] == 'm' && a[i + 1] == 'e' && a[i + 2] == 't' && a[i + 3] == 'a' &&
        a[i + 4] == 'l') {
      output += count;
    }
  }
  cout << output << endl;
  return 0;
}
