MMO 2015 Problem 2

MMO 2015 Problem 2

Solution