resolve :: Int -> Int -> Int -> Int
resolve x 0 _ = x
resolve x k d
  | abs (x - d) > x  = if even k then x else x - d
  | abs (x - d) <= x = resolve (x - d) (k - 1) d

main :: IO ()
main = do
    [x, k, d] <- getLine >>= return . map read . words
    let ans = resolve (abs x) k d
    print $ abs ans
