import kotlin.math.abs
import kotlin.math.min

fun main(){
    val (x, k, d) = readLine()!!.split(" ").map { it.toLong() }
    if (x >= 0){
        val saitan = x / d
        if (k <= saitan){

            println(abs(x - k * d))

        } else {
            if ((k - saitan) % 2 == 0L){
                println(abs(x % d))
            } else {
                println(abs(x % d - d))
            }
        }
    } else {
        val useX = x * -1
        val saitan = useX / d
        if (k <= saitan){

            println(abs(x + (k * d )))

        } else {
            if ((k - saitan) % 2 == 0L){
                println(abs(x % d))
            } else {
                if (x % d > 0){
                    println(abs(x % d -d))
                } else {
                    println(abs(x % d + d))
                }
            }
        }
    }
}