Solution to the digit statistics problem.