Counting the occurrences of each word