#P6882. [COCI 2016/2017 #3] Imena

[COCI 2016/2017 #3] Imena

Problem 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 NN sentences, Mirko wants you to count how many names there are in each sentence.

Input Format

The first line contains a positive integer NN, the number of sentences.

The second line contains these NN sentences. The total number of characters of these sentences does not exceed 10310^3.

Output Format

Output NN lines, each containing one positive integer. The ii-th line should contain the total number of names in the ii-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 11 in total. In the second sentence, the names are Ana and Banana, so there are 22 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%40\% of the testdata, N=1N=1.

For 100%100\% of the testdata, 1N51 \le N \le 5.

Notes

This problem is translated from COCI2016-2017 CONTEST #3 T1 Imena.

Translated by ChatGPT 5