# ABC 175 C
# https://atcoder.jp/contests/abc175/tasks/abc175_c

x, k, d = gets.chomp.split(/ /).map(&:to_i)
xp = x.abs

if xp >= d * k
  puts xp - d * k
  exit
end

if k % 2 == 0
  # 0, 2d, 4d, ..., kd 動く
  # i: xp - 2 * i * d > 0 となる最小の i
  # xp > 2 * i * d
  # i < xp / (2 * d)
  i = xp / (2 * d)
  puts [xp - 2 * i * d, xp - 2 * (i + 1)*d].map(&:abs).min
else
  # d, 3d, 5d, ..., kd 動く
  # i: xp - (2 * i + 1) * d > 0 となる最小の i
  # xp > (2 * i + 1) * d
  # xp - d > 2 * i * d
  # i < (xp - d) / (2 * d)
  i = (xp - d) / (2 * d)
  puts [xp - (2 * i + 1)*d, xp - (2 * i + 3)*d].map(&:abs).min
end
