let [| X; K; D; |] = stdin.ReadLine().Split() |> Array.map int64

let newX, newK = 
    if K % 2L = 0L then X, K 
    else
    if X > 0L then X - D, K - 1L
    else X + D, K - 1L

let minAddress = 
    let maxPlus = X + K * D
    let minMinus = X - K * D
    let getMinDistance =
        let newX, newK = 
            if K % 2L = 0L then X, K 
            else
            if X > 0L then X - D, K - 1L
            else X + D, K - 1L
        min (newX % (2L * D)) ((2L * D) - newX % (2L * D)) 

    match maxPlus > 0L, minMinus > 0L with
    | true, true -> minMinus
    | true, false -> getMinDistance
    | false, false -> maxPlus
    | false, true -> 0L

minAddress |> stdout.WriteLine