import scala.math.BigInt.long2bigInt

object Main extends App {
  val params = io.StdIn.readLine().split(" ").map(_.toLong)
  var x = params(0)
  var k = params(1)
  var d = params(2)
  var ans: Long = 0

  x = Math.abs(x)
  val stright : Long = Math.min(k, x / d)
  k -= stright
  x -= stright * d

  if ((k mod 2) == 0)
    ans = x
  else
    ans = Math.abs(x - d)

  println(ans)
}
