import Data.Maybe
import Data.List
import Text.Printf
import qualified Data.ByteString.Char8 as C

getInts :: IO [Int]
getInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [x, k, d] <- getInts
  let f a = abs $ abs x - a * d
      t = min k $ (\a -> if odd a /= odd k then (if a == 0 then 1 else a - 1) else a) $ abs x `div` d
      ans = minimum $ map f $ nub [t, if t + 2 <= k then t + 2 else t]
  printf "%d\n" ans
