#include <bits/stdc++.h>
using namespace std;
int modulo(int a, int b, int c) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y) % c;
    }
    y = (y * y) % c;
    b /= 2;
  }
  return x % c;
}
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int main() {
  string s;
  cin >> s;
  int l, cnt;
  long long int ans = 0;
  l = int((s).size());
  cnt = 0;
  for (int i = 0; i < (l - 5 + 1); i++) {
    if (s[i] == 'h' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'v' &&
        s[i + 4] == 'y')
      cnt++;
    if (s[i] == 'm' && s[i + 1] == 'e' && s[i + 2] == 't' && s[i + 3] == 'a' &&
        s[i + 4] == 'l')
      ans += cnt;
  }
  cout << ans << endl;
  return 0;
}
