x, k, d = gets.split.map(&:to_i)
dist = 0
if x.abs > k * d
  dist = x.abs - k * d
elsif (k - (x.abs / d).ceil).odd?
  if x.abs % d == 0
    dist = d
  else
    dist = x.abs - (x.abs / d)*d
  end
else
  t = (x.abs / d).ceil
  dist = x.abs - t * d
end

puts dist