50132. Only Consonants

I'm a slow walker, but I never walk backwards.

Task Description

We want to count the number of consonants that are alphabetically "less" than the consonant right in front of them, among multiple words. We will be given lines of words. Each word contains at least one letter and all letters are in lowercase. First we remove the vowels from all the words and then imagine that we concatenate all the remaining consonants as a single string. Then we count the number of consonants that are alphabetically "less" than the consonant right in front of them, and print this number as the answer.

a programmer
is a person
who creates computer software

Let us illustrate the task by Sample Input 3 above. First we put all the consonants into a string “prgrmmrsprsnwhcrtscmptrsftwr”. Then we compare each letter in this string with the letter right in front of it, and count the answer in the process.

  • The first letter 'p' is less than ‘r’ so this does count.
  • The second letter 'r' is greater than ‘g’ so this does not count.
  • The third letter 'g' is less than ‘r’ so this does count.
  • The fourth letter ‘r’ is greater than ‘m’, so this does not count.
  • The fifth letter ‘m’ is equal to ‘m’, so this does not count.

Finally, the count is 15 and we print it out. Please refer to the following figure for an illustration.

figurefigure

You can use “strtok” function to split a word into multiple strings, which are sequences of contiguous consonants separated by vowels. Then you compute the answer from these strings.

There is an easy way to count the answer. you can use “strcat” function to concatenate all strings from "strtok" together, then compute the answer by scanning through this long string, as we showed in the figure above. Although this is simple, it wastes memory because you do not need to keep everything in memory in order to compute the answer. Instead you can process the strings from "strtok" one at a time and still be able to count the answer. The idea is to always remember the last character from the previous consonant string. You can only complete subtask 4 by doing this.

Input Format

The input has multiple lines and you must process them until EOF. Each line may have multiple words. All letters are in lowercase and contains at least one consonant.

$W$ is the max length of a word and $C$ is the total number of characters (including '\0') in all words.

  • $W \lt 32$
  • $C \lt 500000$

Output Format

Print the number of consonants that are alphabetically "less" than the consonant right in front of them.

Subtasks

  • 10 points: There is only one word, and this word contains only consonants.
  • 10 points: There is only one word, and this word contains vowels.
  • 40 points: Words may contain vowels. The input data is less than 10000 characters.
  • 40 points: Words may contain vowels. The input data may be large. You may get MLE if your algorithm wastes unnecessary memory.

Sample Input 1

dzffmb

Sample Output 1

2

Sample Input 2

oxaloacetate

Sample Output 2

1

Sample Input 3

a programmer
is a person
who creates computer software

Sample Output 3

15

Sample for subtask 1 ~ 3

Inside the testdata.

Discussion