-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS

naive :: Integer -> Integer -> Integer -> Integer
naive x k d = minimum $ map abs $ iterate (>>= oneStep) (pure x) !! fromInteger k
  where
    oneStep :: Integer -> [Integer]
    oneStep y = [y + d, y - d]

main = do
  [x,k,d] <- unfoldr (BS.readInteger . BS.dropWhile isSpace) <$> BS.getLine
  print $ naive x k d
