w, d = io.read("*n", "*n") for i = d, 1, -1 do if(i == 1) then io.write(w) else w = w - math.floor(w / i / i) end end