
import kotlin.math.*

fun main() {
    val list = readLine()!!.split(" ")
    val x = list[0].toLong()
    val k = list[1].toLong()
    val d = list[2].toLong()
    val minimum: Double = x.toDouble() / 1000000.0 - k * d.toDouble() / 1000000.0
    val maximum: Double = x.toDouble() / 1000000.0 + k * d.toDouble() / 1000000.0

    if (k == 0L || d == 0L) {
        println(x)
    }else if (maximum * minimum >= 0) {
        if (x < 0) {
            println(abs(x + k * d))
        } else if (x > 0) {
            println(abs(x - k * d))
        }
    } else if (minimum < 0 && x >= 0) {
        val howMany: Long = x / d
        val nam: Long = k - howMany
        if (nam % 2 == 1L) {
            println(min(abs(x - (howMany - 1) * d), abs(x - (howMany + 1) * d)))
        } else {
            println(abs(x - howMany * d))
        }

    } else if (minimum < 0 && x < 0) {
        val howMany: Long = (-x) / d
        val nam: Long = k - howMany
        if (nam % 2 == 1L) {
            println(min(abs(x + (howMany - 1) * d), abs(x + (howMany + 1) * d)))
        } else {
            println(abs(x + howMany * d))
        }


    }
}