#include <bits/stdc++.h>
using namespace std;
const int oo = (int)(1e9);
const long double PI = 3.141592653589793;
int PP = 1000000007;
const int MAXN = 111111 * 2, MAXE = 111111;
template <typename TT>
void read(TT &x) {
  char ch;
  for (ch = getchar(); ch > '9' || ch < '0'; ch = getchar())
    ;
  for (x = 0; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - 48;
}
int n, m, k;
char s[1111111];
char a[5], b[5];
int f[1111111], g[1111111];
void Init() {
  scanf("%s", s);
  ;
  n = strlen(s);
  a[0] = 'h';
  a[1] = 'e';
  a[2] = 'a';
  a[3] = 'v';
  a[4] = 'y';
  b[0] = 'm';
  b[1] = 'e';
  b[2] = 't';
  b[3] = 'a';
  b[4] = 'l';
  f[0] = g[0] = 0;
  for (int i = 0; i < n; i++) {
    bool ok = 1;
    for (int j = 0; j < 5; j++) ok &= (a[j] == s[j + i]);
    if (ok) f[i] = 1;
    ok = 1;
    for (int j = 0; j < 5; j++) ok &= (b[j] == s[j + i]);
    if (ok) g[i]++;
    g[i + 1] = g[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; i++)
    if (f[i]) {
      ans += g[n] - g[i];
    }
  cout << ans;
}
int main() { Init(); }
