local abs = math.abs
local X, K, D = io.read("n", "n", "n")

local X_is_minus = (X < 0)
local carrent_X, K_of_carrent_X
if X_is_minus then
	K_of_carrent_X = X // D + 1
	carrent_X = X % D - X
	if K <= K_of_carrent_X then
		print(abs(X + K * D))
	elseif (K - K_of_carrent_X) % 2 == 0 then
		print(abs(carrent_X))
	else
		print(abs(carrent_X + D))
	end
else
	K_of_carrent_X = X // D
	carrent_X = X % D
	if K <= K_of_carrent_X then
		print(abs(X - K * D))
	elseif (K - K_of_carrent_X) % 2 == 0 then
		print(abs(carrent_X))
	else
		print(abs(carrent_X - D))
	end
end
