f :: Integer -> Integer -> Integer -> Integer
f x k d =
    let np = min (abs x - d) (abs x + d)
    in if k == 1 then np else (f 0 (k - 1) 0)
    
main = do
    [x, k, d] <- map read . words <$> getLine
    putStrLn $ show $ f x k d