import java.util.*

import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val x = sc.nextLong()
  val k = sc.nextLong()
  val d = sc.nextLong()


  val xd = Math.abs(x) / d
  if (k <= xd) {
    println(Math.abs(x) - k * d)
    return
  }


  val min1 = Math.abs(x) - d * xd
  val min2 = Math.abs(min1) - d
  val min3 = Math.abs(min2)


  val last = k - xd
  if (last % 2 == 0L) {
    println(min1)
  } else {
    println(min3)
  }



}