function Main(input) {
  const [x, k, d] = input.trim().split(" ").map((a) => parseInt(a, 10));
  const absX = Math.abs(x);
  const remainder = absX % d;
  if (absX <= d) {
    if (k % 2 === 0) {
      console.log(absX);
    } else {
      console.log(Math.abs(d - absX));
    }
  } else {
    const n = Math.floor(absX / d);
    if (n === k) {
      console.log(remainder);
    } else if( n < k ) {
      if (remainder === 0) {
        const rem = k - n;
        if (rem % 2 === 0){
	        console.log(d);        
        } else {
          console.log(remainder);
        }
      } else {
        console.log(remainder);
      }
    } else {
      console.log(absX - k * d);
    }
  }
}

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