The first line of the input contains a natural number k. The
following lines contain a text made up of one or more lines.
Determine and print how many words in the text have exactly k letters.
A word is a maximal sequence of English letters (a-z or
A-Z); digits, spaces, and punctuation marks are not part of
a word.
The data are read from standard input (in the format described), not from a
file. After reading k with cin >> k, use cin.ignore()
to skip the newline, then cin.getline for
each line of text.
Input:
The first line contains the natural number k. The following lines contain
the text, until end of input.
- 1 <= k <= 30
- the number of text lines is between 0 and 100
- each line has at most 4000 characters
Output:
The program prints to standard output a single non-negative integer: how many words
have exactly k letters.
Example:
Input:
3
un mar si o para sunt fructe
Output:
1