Counting number of words correctly