object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val x = sc.nextLong().abs
  val k, d = sc.nextLong()

  val a = x / d
  if (k <= a) {
    println(x - d * k)
  } else if ((a - k) % 2 == 0) {
    println(x - d * a)
  } else {
    println(d - (x - d * a))
  }
}
