Count the frequency of characters in each position