fun main() {
  var (x, k, d) = readLine()!!.split(" ").map(String::toLong)
	
  x = Math.abs(x)
  
  k = k - x/d
  
  if(k <= 0L) {
    println(x-d*(k+x/d))
    return
  }
  
  x = x - d*(x/d)
  
  
  if(k%2==0L) {
    println(x)
  } else {
    println(d-x)
  }
}