import kotlin.math.abs
import kotlin.math.ceil

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

    val res = when {
        k < ceil(x.toDouble() / d) -> {
            x - k * d
        }
        (k - x / d) % 2 == 0L -> {
            x % d
        }
        else -> {
            abs(x % d - d)
        }
    }

    println(res)
}
