Imena
Time limit1sMemory limit32 MB
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 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 ().
The second line contains the sentences of the book in order, separated by spaces. The total number of characters in the book does not exceed .
Output
Print lines. Line contains the number of names in sentence .