cswork / OAOpen practice workspace

NutanixOA #1

Good Subsequences

Estimated MediumJudge-ready

Topics (AI-labelled)Bits & MathHashing

Count the non-empty subsequences in which every character that appears has the same frequency, modulo 1,000,000,007. Choosing the same character from different indices gives different subsequences.

The standard input/output format and any supplementary ranges on this site are as defined in this problem statement.

Input

One line containing word, consisting only of lowercase English letters; this site adds 1≤|word|≤200000 to fill in the length upper bound the original problem did not give.

Output

Output the number of qualifying non-empty subsequences modulo 1,000,000,007.

Example 1

Input:

abca

Output:

12

Example 2

Input:

abcd

Output:

15

Example 3

Input:

aaa

Output:

7

Editorial

Loading solution…