Code for problem 355B.