solved digit counting