f x k d = abs (if (n<=k) then g (x - n*d) (k-n) d else g (x - k*d) 0 d) `min` abs(if (n<=k) then g (x - n'*d) (k-n') d else g (x - k*d) 0 d)
  where
    n = (x `div` d)
    n' = (x`div` d)+1

g x k d = if k`mod`2 == 0 then x else abs (x - d) `min` abs (x + d)

main = do
  [x, k, d] <- map read . words <$> getLine
  print $ abs $ f (abs x) k d