#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s1;
  cin >> s1;
  long long heavy_count = 0, ans = 0;
  if (s1.size() > 5) {
    for (int i = 0; i < s1.size() - 5 + 1; i++) {
      if (s1[i] == 'h' && s1[i + 1] == 'e' && s1[i + 2] == 'a' &&
          s1[i + 3] == 'v' && s1[i + 4] == 'y') {
        heavy_count++;
      } else if (s1[i] == 'm' && s1[i + 1] == 'e' && s1[i + 2] == 't' &&
                 s1[i + 3] == 'a' && s1[i + 4] == 'l') {
        ans += heavy_count;
      }
    }
  }
  cout << ans;
}
