import Foundation

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

if(abs(n[0]) >= n[1] * n[2]){
  print(abs(n[0]) - n[1] * n[2])
}else{
  n[1] -= abs(n[0]) / n[2]
  n[0] = abs(n[0]) % n[2]
  if(n[1] % 2 == 1){
    let dis = n[2] - n[0]
    print(dis)
  }else{
    print(n[0])
  }
}