refactor count_chars and start on exercise_2_1