593 div2 problem 2. on a roll.