A solution that counts the number of occurrences of words in given Strings