import Foundation

let XKD = readLine()!.split(separator: " ").compactMap { Int($0) }
let X = XKD[0]
let K = XKD[1]
let D = XKD[2]

var minValue: Int
var requiredValue: Int
if X <= 0 {
    minValue = (-1 * X) % D
    requiredValue = (-1 * X) / D
} else {
    minValue = X % D
    requiredValue = X / D
}

if requiredValue < K {
    let isOdd = (K - requiredValue) % 2 != 0
    if requiredValue % 2 == 0 {
        if isOdd {
            print(abs(minValue))
        } else {
            print(abs(minValue - D))
        }
    } else {
        if isOdd {
            print(abs(minValue - D))
        } else {
            print(abs(minValue))
        }
    }
} else {
    if X <= 0 {
        print(X + K * D)
    } else {
        print(X - K * D)
    }
}
