Solve srm633 div2 medium.