Program to count number of words from given input