Slightly optimized Problem 20.