P6882 [COCI 2016/2017 #3] Imena

Description

A word is a string made of uppercase or lowercase letters. In particular, it may also end with a punctuation mark (`.`, `?`, `!`). A name is a word whose **first letter is uppercase, and only the first letter is uppercase**. A sentence is a string made of some words, and its last character is a punctuation mark (`.`, `?`, `!`). Given $N$ sentences, Mirko wants you to count how many names there are in each sentence.

Input Format

The first line contains a positive integer $N$, the number of sentences. The second line contains these $N$ sentences. The total number of characters of these sentences does not exceed $10^3$.

Output Format

Output $N$ lines, each containing one positive integer. The $i$-th line should contain the total number of names in the $i$-th sentence.

Explanation/Hint

### Sample Explanation #### Sample 2 Explanation In the first sentence, the only name is `Milovana`, so there is $1$ in total. In the second sentence, the names are `Ana` and `Banana`, so there are $2$ 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 $40\%$ of the testdata, $N=1$. For $100\%$ of the testdata, $1 \le N \le 5$. ### Notes **This problem is translated from [COCI2016-2017](https://hsin.hr/coci/archive/2016_2017/) [CONTEST #3](https://hsin.hr/coci/archive/2016_2017/contest3_tasks.pdf) _T1 Imena_.** Translated by ChatGPT 5