Solve problem 123 using Python.