counting words using reduce