let inp = readLine()!.split(separator: " ").map { Int($0)! }

var x = abs(inp[0])
var k = inp[1]
let d = inp[2]

if x / d > k {
  print(x - k * d)
} else {
  k = k - x / d
  x = x % d
  if k == 0 {
    print(x)
  } else if k & 1 == 0 {
    print(x)
  } else {
    print(abs(x - d))
  }
}