import Foundation

let input = readLine()!.components(separatedBy: " ").map { Int($0)! }
let x = input[0]
let k = input[1]
let d = input[2]

let res: Int
if (x > 0) {
  let c = Int(ceil(Double(x) / Double(d)))
  if c > k {
    res = x - k * d
  } else {
    let r = k - c
    if (r % 2 == 0) {
      res = x - c * d
    } else {
      res = x - c * d + d
    }
  }
} else {
  let c = Int(ceil(abs(Double(x)) / Double(d)))
  if c > k {
    res = x + k * d
  } else {
    let r = k - c
    if (r % 2 == 0) {
      res = x + c * d
    } else {
      res = x + c * d - d
    }
  }
}

print(abs(res))
