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

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

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