solve :: [Int] -> Int
solve [x,k,d]
 | even exceededNumberOfWalking = x - numberOfWalking * d
 | otherwise                    = x - (numberOfWalking - 1) * d 
  where numberOfWalking = min k (x `div` d)
        exceededNumberOfWalking = k - numberOfWalking
main = print =<< solve . map read . words <$> getLine