Solve #82 in Python.