Count the frequency of each item