function main(lines) {
  const [X, K, D] = lines[0].split(' ').map(BigInt);

  let sign = X > 0 ? -1 : 1;
  sign = BigInt(sign);
  let ans;
  if (X/D*(-sign) > K)
    ans = X + K*D*sign;
  else {
    ans = X % D;
    const restK = K - X/D*(-sign);
    if (restK % BigInt(2) == 0) ans += D*(sign);
  }
  
  return ans.toString();
}


const ans = main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );
console.log( ans );

function splitN(s) {
  return s.split(' ').map(Number);
}
