local x, k, d = io.read("*n", "*n", "*n")
x = math.abs(x)
local a = x // d
if k <= a then
  print(x - d * k)
else
  k = k - a
  x = x - d * a
  if k % 2 == 0 then
    print(x)
  else
    print(d - x)
  end
end
