#include <bits/stdc++.h>
using namespace std;
int main() {
  char arr[1000001];
  cin >> arr;
  long long int len = strlen(arr);
  long long int cnt = 0;
  long long int inc = 0;
  long long int m = 4;
  for (long long int i = m; i < len; i++) {
    if (arr[i - 4] == 'h' && arr[i - 3] == 'e' && arr[i - 2] == 'a' &&
        arr[i - 1] == 'v' && arr[i] == 'y') {
      inc++;
      i = i + 4;
    }
    if (arr[i - 4] == 'm' && arr[i - 3] == 'e' && arr[i - 2] == 't' &&
        arr[i - 1] == 'a' && arr[i] == 'l') {
      cnt += inc;
      i = i + 4;
    }
  }
  cout << cnt << endl;
  return 0;
}
