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-----

Input contains a single non-empty string consisting of the lowercase Latin alphabet letters. Length of this string will not be greater than 10^6 characters.


-----Output-----

Print exactly one number — the number of powerful substrings of the given string.

Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.


-----Examples-----
Input
heavymetalisheavymetal

Output
3
Input
heavymetalismetal

Output
2
Input
trueheavymetalissotruewellitisalsosoheavythatyoucanalmostfeeltheweightofmetalonyou

Output
3


-----Note-----

In the first sample the string "heavymetalisheavymetal" contains powerful substring "heavymetal" twice, also the whole string "heavymetalisheavymetal" is certainly powerful.

In the second sample the string "heavymetalismetal" contains two powerful substrings: "heavymetal" and "heavymetalismetal".

Difficulty: interview

Starter code:

Solutions:
s=input()
ans=0
s=s.replace("heavy","1")
s=s.replace("metal","2")
heavy=[]
metal=[]
n=len(s)
for i in range(n):
    if(s[i]=="1"):
        heavy.append(i)
    elif(s[i]=="2"):
        metal.append(i)

n=len(heavy)
nn=len(metal)
x=0
l=nn
for item in heavy:
    for i in range(x,nn):
        if(metal[i]>item):
            ans+=(nn-i)
            l=i
            break
    x=l;

print(ans)


L = input().split('heavy')
ans = 0
for i in range(len(L)):
    ans += i*L[i].count('metal')
print(ans)


z=r=0
for w in input().split("heavy"):r+=w.count("metal")*z;z+=1
print(r)


s = input().strip()
ans = 0
head = 0
for i in range(4, len(s)):
    if s[i - 4: i + 1] == "heavy":
        head += 1
    if s[i - 4: i + 1] == 'metal':
        ans += head
print(ans)


s = input()
s = s.replace("heavy", "1")
s = s.replace("metal", "0")
tmp = ""
for i in s:
    if(i == "1"):
        tmp += "1"
    if(i == "0"):
        tmp += "0"
if len(tmp) == 0:
    print(0)
    return
d = [0 for i in range(10**6+1)]
if tmp[len(tmp)-1] == "0":
    d[len(tmp)-1] = 1
for i in reversed(list(range(len(tmp) - 1))):
    if tmp[i] == "0":
        d[i] = d[i+1] + 1
    else:
        d[i] = d[i+1]
res = 0
for i in range(len(tmp)):
    if tmp[i] == "1":
        res += d[i]
print(res)


str = input()
heavy = 0
ans = 0
for i in range(0, len(str)):
    if str[i:i + 5] == "heavy":
        heavy += 1
    elif str[i:i + 5] == "metal":
        ans += heavy
print(ans)


s = input()
a = 0
su = 0

for i in range(len(s)):
	if s[i : i + 5] == 'heavy':
		a += 1
	elif s[i : i + 5] == 'metal':
		su += a
print(su)


#!/usr/bin/env python3

def main():
    line = input()
    final = 0
    count = 0
    for i in range(len(line)-4):
        if 'heavy' == line[i:i+5]:
            count += 1
            i += 5
        elif 'metal' == line[i:i+5]:
            final += count
            i += 5
    print(final)

def __starting_point():
    main()

__starting_point()

L=list(input().split("heavy"))
ans=0
for i in range(len(L)):
    ans += i*(len(list(L[i].split("metal")))-1)
print(ans)


def main():
    s=str(input())
    s=s.replace("heavy","-")
    s=s.replace("metal","+")
    p,n=0,0
    for k in s:
        if (k=="-"):
            n+=1
        elif k=="+":
            p+=(n)
    print(p)        
main()
    


input_str = input()
if input_str.find('heavy') == -1:
    print(0)
else:
    a = input_str.index('heavy')+5
    b = 1
    result = 0
    while a < len(input_str):
        if input_str[a:(a+5)] == 'heavy':
            b+=1
            a+=4
        elif input_str[a:(a+5)] == 'metal':
            result+=b
            a+=4
        else:
            a+=1
    print(result)

from re import findall
h, acc = 0, 0
for i in findall('heavy|metal', input()):
    if i.startswith('h'): h += 1
    else: acc += h
print(acc)

s = input()
metals = []
heavys = []
ind = cur = -1
while True:
    cur = s.find('heavy', ind + 1)
    if cur != -1:
        heavys.append(cur)
        ind = cur
    else:
        break
ind = cur = -1
while True:
    cur = s.find('metal', ind + 1)
    if cur != -1:
        metals.append(cur)
        ind = cur
    else:
        break
ind = ans = 0
for x in metals:
    while ind < len(heavys) and heavys[ind] < x:
        ind += 1
    ans += ind
print(ans)

l = input().split('metal')
ans = cur = 0
for str in l:
    cur += str.count('heavy')
    ans += cur
print(ans - cur)


subst = input().split('heavy')

res = 0
for i in range(len(subst)):
    res += i * subst[i].count('metal')

print(res)



res = 0
i = 0
for word in input().split('heavy'):
    res += i * word.count('metal')
    i += 1

print(res)


ans = 0
s = input()
heavy = 0
i = 0
if not len(s) < 5:
    while i < len(s) - 4:
        if s[i] == 'h' and s[i + 1] == 'e' and s[i + 2] == 'a' and s[i + 3] == 'v' and s[i + 4] == 'y':
            heavy += 1
            i += 5
        elif s[i] == 'm' and s[i + 1] == 'e' and s[i + 2] == 't' and s[i + 3] == 'a' and s[i + 4] == 'l':
            ans += heavy
            i += 5
        else:
            i += 1
print(ans)

s = input()
heavy = 0
total = 0

i = 0
while i < len(s) - 4:
    if s[i:i + 5] == 'heavy':
        i += 5
        heavy += 1
    elif s[i:i + 5] == 'metal':
        i += 5
        total += heavy
    else:
        i += 1


print("%d" % total)


t = input()
t = t.replace('heavy', '0')
t = t.replace('metal', '1')

a, b, s = 0, t.count('1'), 0
for i in t:
    if i == '0':
        a += 1
        s += b
    if i == '1': b -= 1
print(s)

t = input()
t = t.replace('heavy', '0')
t = t.replace('metal', '1')

a, b, s = 0, t.count('1'), 0
for i in t:
    if i == '0':
        a += 1
        s += b
    elif i == '1': b -= 1
print(s)

s = input()
l = len(s)
k = [ 0 for i in range(l) ]

start = 0
while True:
    temp = s.find("heavy",start,l)
    if temp==-1:
        break
    else:
        k[temp] = 1
        start = temp+1

start = 0
while True:
    temp = s.find("metal",start,l)
    if temp==-1:
        break
    else:
        k[temp] = 2
        start = temp+1

sol = 0
ones = 0
for i in range(l):
    if k[i]==1:
        ones+=1
    elif k[i]==2:
        sol+=ones

print(sol)


#!/usr/bin/env python

import re

def main( ):
    l = input( )

    heavyCnt = 0
    res = 0
    for i in range( 4, len( l ) ):
        if l[ i - 4 : i + 1 ] == "heavy": heavyCnt += 1
        if l[ i - 4 : i + 1 ] == "metal": res += heavyCnt

    print( res )


def __starting_point():
    main( )


__starting_point()