Fixed overflow error in count_digits