Solve problem 14 using Python.