Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.

Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequence of consecutive characters in a string) in a given text makes our hero especially joyful. Recently he felt an enormous fit of energy while reading a certain text. So Volodya decided to count all powerful substrings in this text and brag about it all day long. Help him in this difficult task. Two substrings are considered different if they appear at the different positions in the text.

For simplicity, let us assume that Volodya's text can be represented as a single string.
Input contains a single non-empty string consisting of the lowercase Latin alphabet letters. Length of this string will not be greater than 10<sup class="upper-index">6</sup> characters.
#                   بسم الله الرحمن الرحيم
#          صلو على نبينا محمد صلى الله عليه و سلم


##############--->>>>>       Mohamed Mostafa Mohamed Abdelhamed         <<<<<---##############

"""
  ____          _      _____                       
 / ___|___   __| | ___|  ___|__  _ __ ___ ___  ___ 
| |   / _ \ / _` |/ _ \ |_ / _ \| '__/ __/ _ \/ __|
| |__| (_) | (_| |  __/  _| (_) | | | (_|  __/\__ \
 \____\___/ \__,_|\___|_|  \___/|_|  \___\___||___/
"""


ss = input()
# tt = list()
# for i in range(len(ss)):
#     if ss[i] == "h" and ss[i + 1] == "e" and ss[i + 2] == "a":
#         tt.append(ss[i : i + 5])
#     if ss[i] == "m" and ss[i + 1] == "e" and ss[i + 2] == "t":
#         tt.append(ss[i : i + 5])
print((ss.count("heavy") // 2) + ss.count("metal"))
