By TopCoder* USA
An alliteration consists of two or more consecutive words which start with the same letter (ignoring case). You are given a sequence of words. Find out the number of alliterations in this sequence, considering only alliterations which cannot be extended.
The input contains several test cases. Each input line will be a test case, containing at least one and no longer than 100 words, separated by a single space character. All words are strings of 1 to 50 lowercase or uppercase letters ('A'-'Z','a'-'z'). The input stream ends in EOF.
For each test case print the number of alliterations found among the given words. For further reference see the examples below.
Sample Input | Sample Output |
He has four fanatic fantastic fans |
2 |