You are given a string of lowercase letters. Turn it into a sentence of uppercase letters with these two steps.
- Delete any letters you want. There is no limit on how many letters you delete, the deleted letters do not have to be adjacent, and deleting nothing is allowed.
- Read the remaining string in groups of three from the left. Every group must consist of three copies of the same letter, and each group becomes one uppercase copy of that letter.
The second step works only when the remaining string is a concatenation of groups of three equal letters. The finished sentence contains at least one uppercase letter.
For example, bbcccaabbba produces these five sentences.
- Keeping only aaa gives A.
- Keeping only bbb gives B.
- Keeping only ccc gives C.
- Keeping only cccaaa gives CA.
- Keeping only cccbbb gives CB.
Two different sets of deletions that end in the same sentence count once. Count the distinct sentences you can build.