Count the strings W of the same length as T that produce T on a machine that reverses the line every time a vowel is typed.
Medium7CombinatoricsStringDynamic programmingNo attempts yetTime limit1sMemory limit1024 MBAlan Curing is a famous competitive programmer. He created the model of computation known as the Alan Curing Machine (ACM), and he built his own computer for programming contests, the Integrated Computer for Programming Contests (ICPC). Its operating system has commands for submitting code and for running executables on sample inputs, an input generator, a wide display for debugging, and a very soft keyboard. Even the best work keeps its flaws, and Alan's computer has a nasty bug. Every time Alan types a vowel, the content of the current line is reversed.
The bug has been extremely hard to track down, so Alan decided to accept the challenge and use the computer as it is. He is training touch typing on the ICPC, typing lowercase letters only and no spaces. When Alan types a consonant, it is appended to the end of the current line. When he types a vowel, the character is appended to the end of the line and right after that the whole line is reversed. For example, if the current line is imc and Alan types a, the line becomes imca for a brief moment and then the bug turns it into acmi. If he then types the consonants c, p and c in that order, the line becomes acmicpc.
When practicing, Alan first thinks of the text he wants to type, then looks for a sequence of characters that produces it. Some texts cannot be obtained at all, such as ca, and other texts have several ways, such as ac, which comes out of typing ac and also out of typing ca. A way of typing a text T is encoded by a string W of ∣T∣ characters: typing W1,W2,…,W∣T∣ on the ICPC in that order leaves the line equal to T, with the bug taken into account. Two ways are different when their strings W are different. The letters that trigger the bug are a, e, i, o and u. Count the ways Alan can type the text T.
The first line contains the string T that Alan wants to type on the ICPC. T is not empty, consists of lowercase letters only, and has length at most 105.
Print on the first line the number of distinct ways Alan can type T, with the bug taken into account.