Added countWords template function

Added a countWords template function that counts the words in a
container.