The answer to the riddle is 20. He will use 9 in 9,19,29,39,49,59,69,79,89,90,91,92,93,94,95,96,97,98,99 (twice in 99). So, ark have to paint the number nine for 20 times.