Implemented problem 112