Problem2 solution