#include <bits/stdc++.h>
using namespace std;
const int NMax = 1001000;
char A[NMax];
int N;
long long sum[NMax];
vector<int> S;
int main() {
  scanf("%s", A);
  N = strlen(A);
  for (int i = 4; i < N; i++) {
    if (A[i - 4] == 'h' && A[i - 3] == 'e' && A[i - 2] == 'a' &&
        A[i - 1] == 'v' && A[i - 0] == 'y')
      S.push_back(0);
    if (A[i - 4] == 'm' && A[i - 3] == 'e' && A[i - 2] == 't' &&
        A[i - 1] == 'a' && A[i - 0] == 'l')
      S.push_back(1);
  }
  for (int i = S.size() - 1; i >= 0; i--) sum[i] = sum[i + 1] + S[i];
  long long ret = 0;
  for (int i = 0; i < S.size(); i++)
    if (S[i] == 0) ret += sum[i + 1];
  printf("%I64d\n", ret);
  getchar();
  getchar();
  return 0;
}
