Solution to word-count exercise