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

local abs_X = abs(X)

local K_of_carrent_X = abs_X // D
local carrent_X = abs_X % D
if K <= K_of_carrent_X then
	print(abs(abs_X - K * D))
elseif (K - K_of_carrent_X) % 2 == 0 then
	print(abs(carrent_X))
else
	print(abs(carrent_X - D))
end
