resolve :: Int -> Int -> Int -> Int
resolve x 0 _ = x
resolve x k d
  | x <= abs (x - d) = if even k then x else x - d
  | x > abs (x - d) = case x `div` d of
                         q
                           | q == 0 -> x
                           | q >= k -> resolve (x - d * k) 0 d
                           | q < k  -> resolve (x - d * q) (k - q) d

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