import Foundation

func main() {
    guard let line = readLine() else { return }
    let inputs = line.components(separatedBy: " ").compactMap() { Int($0) }
    let x = inputs[0]
    let k = inputs[1]
    let d = inputs[2]
    var tmp = 0
    
    if abs(x) / d < k {
        for i in 1...k {
            if abs(x) < i * d {
                tmp = i
                break
            }
        }
        if (k - tmp) % 2 == 0 {
            print(tmp * d - abs(x))
        } else {
            print(tmp - ((tmp * d) - abs(x)))
       }
    } else  {
        print(abs(x) - k * d)
    }
}


main()
