Problem 40

Python 2.7