#P6882. [COCI 2016/2017 #3] Imena
[COCI 2016/2017 #3] Imena
Problem Description
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 N 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 Format
The first line contains a positive integer , the number of sentences.
The second line contains these sentences. The total number of characters of these sentences does not exceed .
Output Format
Output lines, each containing one positive integer. The -th line should contain the total number of names in the -th sentence.
1
Spavas li Mirno del Potro Juan martine?
4
2
An4 voli Milovana. Ana nabra par Banana.
1
2
Hint
Sample Explanation
Sample 2 Explanation
In the first sentence, the only name is Milovana, so there is in total. In the second sentence, the names are Ana and Banana, so there are in total. Note that in the first sentence, although An4 starts with an uppercase letter, it contains a digit, so it is not a name.
Constraints
For of the testdata, .
For of the testdata, .
Notes
This problem is translated from COCI2016-2017 CONTEST #3 T1 Imena.
Translated by ChatGPT 5