integer::W,D,tmp read *,W,D do while(D.gt.1) tmp = W/(D*D) D = D-1 W = W-tmp end do print '(i0)', W end program