#P2246. Counting Hello World Subsequences

    ID: 15524 Type: Default 1000ms 256MiB

Counting Hello World Subsequences

Counting Hello World Subsequences

Given a text consisting of English letters (both uppercase and lowercase), digits, and whitespace characters (tabs, spaces, and newlines), count the number of subsequences that equal Hello World after ignoring case and whitespace. In other words, first remove all whitespace and convert the text to lowercase, then count the number of ways to obtain the string helloworld as a subsequence.

Note that two subsequences are considered different if and only if the indices of the characters chosen from the original text differ. Since the answer may be very large, output it modulo \(10^9+7\).

inputFormat

The input consists of a single text spanning one or multiple lines. The text may include English letters (in both cases), digits, and whitespace characters (spaces, tabs, and newlines).

outputFormat

Output a single integer: the number of subsequences equal to Hello World (ignoring case and whitespace), taken modulo \(10^9+7\).

sample

Hello World
1