Problem 14 solve, similar to 13.