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

let minAddress = 
    let maxPlus: bigint = bigint X + bigint K * bigint D
    let minMinus: bigint = bigint X - bigint K * bigint 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 > bigint 0 , minMinus > bigint 0 with
    | true, true -> int64 minMinus
    | true, false -> getMinDistance ()
    | false, false -> int64 maxPlus
    | false, true -> 0L

minAddress |> stdout.WriteLine