import kotlin.math.abs

fun main(args: Array<String>) {

    val (x, k, d) = readLine()!!.split(" ").map { it.toLong() }


    //val (x, k, d) = Triple<Long, Long, Long>(1000000000000000 , 1000000000000000 , 1000000000000000 )

    val absx = abs(x)

    val needBestTimes = absx / d
    val bestPos = absx % d

    //println("needBestTimes: $needBestTimes, bestPos: $bestPos")

    val answer = when {
        needBestTimes > k -> {
            //println("case1")
            absx - d * k
        }
        (k - needBestTimes) % 2 == 0L -> {
            //println("case2")
            bestPos
        }
        (k - needBestTimes) % 2 == 1L -> {
            //println("case3")
            abs(bestPos - d)
        }

        else -> {
            0L
        }
    }

    println("$answer")
}
