function main(arg) {
    let [x,k,d]= arg.split(" ").map(Number)

    let dir = x > 0 ? 1 : -1
    let t = parseInt(x*dir/d)
    let a = x - t*d*dir
    k = k - t
    //console.log(`parseInt(x/d)=${t} , x=${x}, k=${k}`)
    if(t >= k) {
        //console.log(1)
        console.log(Math.abs(x-(k+t)*d*dir))
    } else {
        //console.log(`k=${k}, t=${t}, d=${d}, a=${a}`)
        console.log(k%2 ? Math.abs(a-d*dir) : Math.abs(a))
    }
    
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
