Little Mirko likes to type and often gets bored during class, which is why his teacher assigned him a task.
Mirko must retype a book that contains space-separated sentences. In this book, a sentence is an array of one or more space-separated words, where only the last word's character is a punctuation mark (.
, ?
or !
). The rest of the words do not contain punctuation marks.
Words are arrays of characters, either lowercase or uppercase letters of the English alphabet, or digits or, exceptionally, a punctuation mark at the end of the last word in the sentence.
Although he likes typing sentences, Mirko doesn't like typing names. A name is a word that starts with an uppercase letter of the English alphabet, whereas the rest of the characters are lowercase letters of the English alphabet, except the last character, which can be the punctuation mark. Before he decides to retype the whole thing, Mirko wants to know how many names there are in each sentence of the book. Write a programme to help him!
Input Specification
The first line of input contains the integer , the number from the task.
The second line contains sentences from the book. The total number of characters in the book will not exceed .
Output Specification
You must output lines. The line contains the number of names in the sentence.
Scoring
In test cases worth points total, it will hold .
Sample Input 1
1
Spavas li Mirno del Potro Juan martine?
Sample Output 1
4
Sample Input 2
2
An4 voli Milovana. Ana nabra par Banana.
Sample Output 2
1
2
Explanation for Sample Output 2
The word An4
starts with an uppercase letter, but contains a digit and therefore can't be a name.
Comments