const main = (input) => {
  let [x, k, d] = input.trim().split(' ').map(Number)

  const m = Math.min(k, Math.floor(x/d))
  x = x - (m*d)
  k = k - m

  if (k % 2 === 0) return console.log(x)
  else return console.log(x+d)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))