Counting occurances of categories