x, k, d = io.read("*n","*n","*n")

x = math.abs(x)

if math.abs(x) // d >= k then
  print(math.abs(x) - k*d)
else
  k = k - x // d
  x = x - x // d * d
  if (k % 2 == 1) then x = math.abs(x - d) end
  print(x)
end
