Initial version - WA on test #4.
Code for problem 335B.