main::IO()
main = do
  [x,k,d] <- map (read::String->Int) . words <$> getLine
  print $ if div x d >= k then (abs x)-k*d else f (mod (abs x) d) (k-div (abs x) d) d
  
f x k d =  if k==0
  then abs x
  else if abs(x) > abs(x-d)
    then f (x-d) (k-1) d
    else if even k
      then abs x
      else min (abs (x-d)) (abs (x+d))