"use strict"
function main(arg) {
    let [X,K,D] = arg.trim().split("\n")[0].split(" ").map(Number)
    let history = [null,null,null]

    let x = Math.abs(X)
    let i = 0
    if (Math.abs(x - K * D) < Math.abs(x - K * (D-1))) {
        console.log(x - K * D)
        // console.log("aa")
        return
    } else {
        let t = Math.floor(x / D)
        i = t
        x = x - (t * D)
        // console.log(t)
    }

    for (; i < K; i++) {
        let a = Math.abs(x - D)
        let b = Math.abs(x + D)
        if (a < b) {
            x = x - D
        } else {
            x = x + D
        }
        history[0] = history[1]
        history[1] = history[2]
        history[2] = x
        // console.log(history)
        if (history[0] === history[2]) {
            // console.log((K-i) % 2)
            if ((K-i) % 2 === 1) {
                x = history[0]
            } else {
                x = history[1]
            }
            break
        }
    }
    console.log(Math.abs(x))
    // console.log(x)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));