#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
int a[1100000];
int b[1100000];
void init() {}
int main() {
  init();
  string s;
  cin >> s;
  for (int i = 0; i < 1100000; i++) a[i] = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.size() - 1 - i > 0)
      if (s[i] == 'm' && s[i + 1] == 'e' && s[i + 2] == 't' &&
          s[i + 3] == 'a' && s[i + 4] == 'l')
        a[i] = 1;
  }
  int cur = 0;
  for (int i = s.size() - 1; i > -1; i--) {
    cur += a[i];
    b[i] = cur;
  }
  long long ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.size() - 1 - i > 0)
      if (s[i] == 'h' && s[i + 1] == 'e' && s[i + 2] == 'a' &&
          s[i + 3] == 'v' && s[i + 4] == 'y')
        ans += b[i];
  }
  cout << ans;
}
