
import java.util.*
import kotlin.math.absoluteValue
fun main(args: Array<String>) {
    val reader = Scanner(System.`in`)
    var X = reader.nextLong()
    val K = reader.nextLong()
    val D = reader.nextLong()

    X = X.absoluteValue

    val divD = X.div(D)
    var result = 0L
    if(divD >= K) {
        result = X - K*D
    }
    else {
        var reaminD =  X - divD*D
        var reaminCount = K - divD
        if(reaminCount % 2 == 0L){
            result = reaminD
        }
        else {
            result = D - reaminD
        }
    }
    println(result)
}