x,k,d = gets.strip.split.map(&:to_i)
x = -x if x<0
if x / d >= k
  p x - d * k
else
  k0 = x / d
  k0 -= 1 if (k-k0) % 2 != 0
  if k0 + 2 > k
    p x - d * k0
  else
    p [x - d * k0, d * (k0 + 2) - x].min
  end
end
