
solve x k d
    | xdd >= k = x' - (k*d)
    | even k' = xdm
    | otherwise = abs $ xdm - d
        where
            x' = abs x
            xdd = div x' d
            xdm = mod x' d
            k' = k - xdd


main = do
    [x,k,d] <- map read . words <$> getLine :: IO [Integer]
    print $ solve x k d

