inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
X = Math.abs(l.shift() * 1)
K = l.shift() * 1 
D = l.shift() * 1 
xz = Math.abs(X)
if (X / D > K) {
    a = X - (D * K)
} else {
    d = Math.floor(X / D);
    if ((K - d) % 2 === 0) {
        a = Math.min(X % D, D - X % D)
    } else {
        a = Math.max(X % D, D - X % D)
    }
}
console.log(a)