Problem 22 solution.