Indian National Olympiad in Informatics

Online Programming Contest, 6-7 August 2005

IARCS home > OLYMPIAD

Basic Division

Problem 1: Count the number of words, (K Narayan Kumar, CMI)

Your task is to count the number words in the input text. The text will consist of the letters of the English alphabet as well as punctuation marks ' (apostrophe), . (full stop), , (comma), ; (semicolon), :(colon) and white space characters (blank, newline).

For example, consider the following text:

This is a sample piece of text to illustrate this problem.
If you're smart you will solve this right.

There are 19 words in this text (note that "you're" is counted as a single word).

Input format

The first line of input contains a single integer N indicating the number of lines in the input. This is followed by N lines of input text.

Output format

A single integer M indicating the number of words in the given input.

Test data

You may assume that N ≤ 10000 and each line contains at the most 80 letters.

Example

We now illustrate input and output formats using the example described above.

Sample input

2
This is a sample piece of text to illustrate this problem.
If you're smart you will solve this right.

Sample output

19



Copyright (c) IARCS 2003-2018;   Last Updated: 07 Sep 2005