#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
string text;
cin >> text;
vector<int> heavyPos,metalPos;
size_t pos = 0;
while((pos = text.find("heavy",pos)) != string::npos) heavyPos.push_back(pos++);
pos = 0;
while((pos = text.find("metal",pos)) != string::npos) metalPos.push_back(pos++);
long long cnt = 0;
int j = 0;
for(int i = 0 ; i < heavyPos.size(); i ++ ){
for(; j < metalPos.size(); j ++ ){
if(heavyPos[i] < metalPos[j]){
cnt +=metalPos.size()-j;
break;
}
}
}
cout<<cnt<<endl;
return 0;
}