Under construction

Still being built. Things may change

Imena

Time limit1sMemory limit32 MB

Summary
Split a book's text into N sentences and count, for each, how many words are names (uppercase first letter, lowercase rest).
Level

Easy3 of 10

Topics
String, Implementation, Simulation
Solved
No attempts yet

Problem

Mirko likes to type, but he gets bored in class, so his teacher gave him an assignment.

Mirko has to retype a book that holds NN sentences. In this book a sentence is one or more words separated by spaces, and only the last character of the last word is a punctuation mark ('.', '?' or '!'). No other word contains a punctuation mark.

A word is a string of uppercase English letters, lowercase English letters and digits. The one exception is the last word of a sentence, which carries a single punctuation mark at its end.

Mirko likes typing sentences but hates typing names. A name is a word whose first character is an uppercase English letter and whose remaining characters are all lowercase English letters. If the last character is a punctuation mark, drop that mark before applying the test. Before he starts retyping, Mirko wants to know how many names each sentence contains. Write a program that tells him.

Input

The first line contains the integer NN (1≤N≤51 \le N \le 5).

The second line contains the NN sentences of the book in order, separated by spaces. The total number of characters in the book does not exceed 1 0001\,000.

Output

Print NN lines. Line ii contains the number of names in sentence ii.

Examples2

  1. Example 1

    Input
    1
    Spavas li Mirno del Potro Juan martine?
    
    Expected output
    4
    
  2. Example 2

    Input
    2
    An4 voli Milovana. Ana nabra par Banana.
    
    Expected output
    1
    2