module Main where

import System.Environment

ans :: Integer -> Integer -> Integer -> Integer
ans x k d = 
	case abs x >= k * d of
		True -> (abs x) - k * d
		False -> abs $ min ((abs x) - k' * d) ((abs x) - (k' - 2) * d)
	where 	k'' = abs $ x `div` d
		k'  = case k'' `mod` 2 == k `mod` 2 of
			True -> k''
			False -> k'' + 1

main :: IO ()
main = do
	(x:k:d:_) <- fmap (map read . words) $ getLine
	putStrLn . show $ ans x k d