#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long from, to, w;
  edge(long long from, long long to, long long w) : from(from), to(to), w(w) {}
  bool operator<(const edge& e) const { return (w > e.w); }
};
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long fx(long long n, long long md) { return ((n % md) + md) % md; }
void O_o() {
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
int main() {
  O_o();
  string second;
  cin >> second;
  int b = second.find("metal"), prcnt = 0, a = 0;
  long long ans = 0;
  while (b != -1) {
    long long cnt = prcnt;
    string m;
    for (__typeof(b) i = (a) - ((a) > (b)); i != (b) - ((a) > (b));
         i += 1 - 2 * ((a) > (b))) {
      if (i + 5 > b) break;
      m.clear();
      for (__typeof(i + 5) j = (i) - ((i) > (i + 5));
           j != (i + 5) - ((i) > (i + 5)); j += 1 - 2 * ((i) > (i + 5)))
        m += second[j];
      if (m == "heavy") cnt++;
    }
    ans += cnt;
    a = b;
    b = second.find("metal", a + 1, 5);
    prcnt = cnt;
  }
  cout << ans << endl;
}
