Counting the frequency of a term