Problem 0009 solution.