porting counting_characters