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

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