#include <bits/stdc++.h>
using namespace std;
char str[1000005];
int sum[1000005];
int main(void) {
  long long ans;
  int n, i;
  scanf("%s", str + 1);
  n = strlen(str + 1);
  for (i = n - 4; i >= 1; i--) {
    sum[i] = sum[i + 1];
    if (str[i] == 'm' && str[i + 1] == 'e' && str[i + 2] == 't' &&
        str[i + 3] == 'a' && str[i + 4] == 'l')
      sum[i]++;
  }
  ans = 0;
  for (i = 5; i <= n; i++) {
    if (str[i] == 'y' && str[i - 1] == 'v' && str[i - 2] == 'a' &&
        str[i - 3] == 'e' && str[i - 4] == 'h')
      ans += sum[i + 1];
  }
  printf("%lld\n", ans);
  return 0;
}
