const { SSL_OP_SSLEAY_080_CLIENT_DH_BUG } = require("constants");

function Main(input) {
  input = input.split("\n");
  var ans =0;
  var X = parseInt(input[0].split(" ")[0]);
  var K = parseInt(input[0].split(" ")[1]);
  var D = parseInt(input[0].split(" ")[2]);
  if(X<0){
    X=-X;
  }
  if(X==0){
    if(D%2==0){
      ans=0;
    }else{
      ans=K;
    }
  }else if(X>K*D){
    ans=X-K*D;
  }else{
    var a = Math.floor(X/D);
    var b = X%D;
    if((K-a)%2==0){
      ans=b;
    }else{
      ans=D-b;
    }
  }


  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));