Codeforces Round 188 (Div. 2)
B
Strings of Power
Codeforces
1300
原题
← AC →
翻译中…

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.

翻译中…

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

翻译中…

样例

Input #1
heavymetalisheavymetal
Output #1
3
InputCopy OutputCopy
Input #2
heavymetalismetal
Output #2
2
InputCopy OutputCopy
Input #3
trueheavymetalissotruewellitisalsosoheavythatyoucanalmostfeeltheweightofmetalonyou
Output #3
3
InputCopy OutputCopy
题目信息
题号
318B
时间限制
2 s
内存限制
256 MB
标签
模拟
字符串
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。