count the instances of a character