import scala.io.StdIn._

object Main extends App {

  val Array(x,k,d) = readLine().split(" ").map(_.toLong)

  def solve() = {
    val xAbs = x.abs
    val movedCnt = xAbs / d
    if(k > movedCnt) {
      val nearP = xAbs % d
      val farP = (xAbs - d).abs
      val fixP = Math.min(nearP, farP)

      if(fixP == nearP) {
        val restMoveCnt = k - movedCnt
        if(restMoveCnt % 2 == 0) nearP else (nearP - d).abs
      } else {
        val restMoveCnt = k - movedCnt - 1
        if(restMoveCnt % 2 == 0) farP else (farP - d).abs
      }
    } else {
      xAbs - (k * d)
    }
  }

  println(solve())

}

