Problem 53: complete solution.