import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val X, K, D = sc.nextLong

  val a = X / D
  val b = X % D
  val c = if (math.abs(b - D) == b) b else Long.MaxValue
  val d =
    if (K - a < 0) X - D * K
    else if ((K - a) % 2 == 0) b
    else math.min(math.abs(b - D), c)

  println(d)
}
