x, k, d = gets.split(" ").map(&:to_i)

cnt = 0
while cnt < k
  if ((x - d).abs <= d) && (x.abs < (x.abs - d).abs)
    break
  end
  x -= d
  cnt += 1
end
if cnt != k && !(cnt % 2 == 0)
  p = (x + d).abs
  m = (x - d).abs
  x = [p, m].min
end
puts x.abs