console.log((args=>{
  const [X,K,D] = args.trim().split` `.map(v=>parseInt(v));
  const x = Math.abs(X);
  if ( x / K > D ) return x - K*D;
  const d = K - Math.floor(x/D);
  return d&1 ? D-x%D : x%D;
})(require('fs').readFileSync('/dev/stdin','utf8')));
