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

f x k d = if k==0
  then abs x
  else if x>0
    then g x (x-d) (k-1) d
    else g x (x+d) (k-1) d
    
g x0 x1 k d = if k==0
  then abs x1
  else if abs(x0) > abs(x1)
    then f x1 k d
    else if odd k 
      then abs x0
      else min (abs x1) (abs (2*x0-x1))