#include <bits/stdc++.h>
using namespace std;
int n, k;
char a[2000009];
const char he[] = {'h', 'e', 'a', 'v', 'y', '\n'};
inline bool checkh(int x) {
  int c;
  for (c = 0; c + x < n && c < 5; c++) {
    if (a[x + c] != he[c]) return 0;
  }
  if (c == 5) return 1;
  return 0;
}
const char met[] = {'m', 'e', 't', 'a', 'l', '\n'};
inline bool checkm(int x) {
  int c;
  for (c = 0; c + x < n && c < 5; c++) {
    if (a[x + c] != met[c]) return 0;
  }
  if (c == 5) return 1;
  return 0;
}
int main() {
  int t, i, j, l, x = 0, y = 0;
  bool di = 0;
  long long count = 0;
  scanf("%s", &a);
  n = strlen(a);
  for (i = 0; i < n;) {
    if (checkh(i)) {
      x++;
      i += 5;
    } else if (checkm(i)) {
      count += (long long)x;
      i += 5;
    } else
      i++;
  }
  cout << count;
  return 0;
}
