first version of a program to count characters
a better version of count-chars