#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1e9;
const long long INF64 = (long long)1e18;
long double eps = 1e-6;
const long double pi = 3.14159265358979323846;
const int N = 1e6 + 100;
long long fact[N], modulo = INF + 7;
int h[N] = {0};
int m[N] = {0};
int main() {
  string a;
  cin >> a;
  int l = a.length();
  for (int i = 0; i < l; i++) {
    if (i + 4 < l)
      if (a[i] == 'h' && a[i + 1] == 'e' && a[i + 2] == 'a' &&
          a[i + 3] == 'v' && a[i + 4] == 'y') {
        h[i] = 1;
      }
  }
  for (int i = 0; i < l; i++) {
    if (i + 4 < l)
      if (a[i] == 'm' && a[i + 1] == 'e' && a[i + 2] == 't' &&
          a[i + 3] == 'a' && a[i + 4] == 'l') {
        m[i] = 1;
      }
  }
  for (int i = l - 2; i >= 0; i--) {
    m[i] = m[i + 1] + m[i];
  }
  long long count = 0;
  for (int i = 0; i < l; i++) {
    if (h[i] == 1) {
      count += m[i];
    }
  }
  cout << count;
}
