#include <bits/stdc++.h>
using namespace std;
template <class F, class T>
T convert(F a, int p = -1) {
  stringstream ss;
  if (p >= 0) ss << fixed << setprecision(p);
  ss << a;
  T r;
  ss >> r;
  return r;
}
const int oo = int(1e9) + 7;
const int dx[] = {1, 0, 0, -1};
const int dy[] = {0, -1, 1, 0};
const int N = int(2e5) + 10;
long long ans = 0LL, c;
string s;
int main() {
  cin >> s;
  int n = s.length();
  s = s + "......";
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == 'm' && s[i + 1] == 'e' && s[i + 2] == 't' && s[i + 3] == 'a' &&
        s[i + 4] == 'l')
      c++;
    if (s[i] == 'h' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'v' &&
        s[i + 4] == 'y')
      ans += c;
  }
  cout << ans;
  return 0;
}
