Round 2 problem B solution