result = 2e50
X, K, D = map(int, input().split())

if (X < 0):
	lo, hi = 0, K
	while (lo < hi):
		mid = int(lo+ (hi - lo) / 2)
		if (X + mid*D >= 0):
			hi = mid;
		else:
			lo = mid + 1;
	if (X + hi*D < 0):
		p1 = hi
		if (abs(X + p1*D) < result):
			result = abs(X + p1*D)
	else:
		p1 = lo
		rem1 = K - p1
		if (rem1%2 == 1):
			result = min((result, abs(X + p1*D + D), abs(X + p1*D - D)))
		p2 = lo - 1
		rem2 = K - p2
		if (rem2%2 == 1):
			result = min((result, abs(X + p2*D + D), abs(X + p2*D - D)))
	print(result)
elif (X > 0):
	lo, hi = 0, K
	while (lo < hi):
		mid = int(lo+ (hi - lo) / 2)
		if (X - mid*D <= 0):
			hi = mid;
		else:
			lo = mid + 1
	if (X - hi*D > 0):
		p1 = hi;
		if (abs(X - p1*D) < result):
			result = abs(X - p1*D)
	else:
		p1 = lo
		rem1 = K - p1
		if (rem1%2 == 1):
			result = min((result, abs(X - p1*D - D), abs(X - p1*D + D)))
		p2 = lo - 1;
		rem2 = K - p2
		if (rem2%2 == 1):
			result = min((result, abs(X - p2*D - D), abs(X - p2*D + D)))
	print(result)
else:
	if (K%2 == 1):
		print(D)
	else:
		print(0) result = 2e50 result 2e50 X, K, D = map(int, input().split()) X map(int, input().split()) map int input().split() ().split () input split K D if (X < 0):
	lo, hi = 0, K
	while (lo < hi):
		mid = int(lo+ (hi - lo) / 2)
		if (X + mid*D >= 0):
			hi = mid;
		else:
			lo = mid + 1;
	if (X + hi*D < 0):
		p1 = hi
		if (abs(X + p1*D) < result):
			result = abs(X + p1*D)
	else:
		p1 = lo
		rem1 = K - p1
		if (rem1%2 == 1):
			result = min((result, abs(X + p1*D + D), abs(X + p1*D - D)))
		p2 = lo - 1
		rem2 = K - p2
		if (rem2%2 == 1):
			result = min((result, abs(X + p2*D + D), abs(X + p2*D - D)))
	print(result)
elif (X > 0):
	lo, hi = 0, K
	while (lo < hi):
		mid = int(lo+ (hi - lo) / 2)
		if (X - mid*D <= 0):
			hi = mid;
		else:
			lo = mid + 1
	if (X - hi*D > 0):
		p1 = hi;
		if (abs(X - p1*D) < result):
			result = abs(X - p1*D)
	else:
		p1 = lo
		rem1 = K - p1
		if (rem1%2 == 1):
			result = min((result, abs(X - p1*D - D), abs(X - p1*D + D)))
		p2 = lo - 1;
		rem2 = K - p2
		if (rem2%2 == 1):
			result = min((result, abs(X - p2*D - D), abs(X - p2*D + D)))
	print(result)
else:
	if (K%2 == 1):
		print(D)
	else:
		print(0) X < 0 X 0 lo, hi = 0, K lo 0 hi K while (lo < hi):
		mid = int(lo+ (hi - lo) / 2)
		if (X + mid*D >= 0):
			hi = mid;
		else:
			lo = mid + 1;
	 lo < hi lo hi mid = int(lo+ (hi - lo) / 2) mid int(lo+ (hi - lo) / 2) int lo+ (hi - lo) / 2 lo (hi - lo) / 2 hi - lo hi lo 2 if (X + mid*D >= 0):
			hi = mid;
		else:
			lo = mid + 1;
	 X + mid*D >= 0 X + mid*D X mid*D mid D 0 hi = mid hi mid lo = mid + 1 lo mid + 1 mid 1 if (X + hi*D < 0):
		p1 = hi
		if (abs(X + p1*D) < result):
			result = abs(X + p1*D)
	else:
		p1 = lo
		rem1 = K - p1
		if (rem1%2 == 1):
			result = min((result, abs(X + p1*D + D), abs(X + p1*D - D)))
		p2 = lo - 1
		rem2 = K - p2
		if (rem2%2 == 1):
			result = min((result, abs(X + p2*D + D), abs(X + p2*D - D)))
	 X + hi*D < 0 X + hi*D X hi*D hi D 0 p1 = hi p1 hi if (abs(X + p1*D) < result):
			result = abs(X + p1*D)
	 abs(X + p1*D) < result abs(X + p1*D) abs X + p1*D X p1*D p1 D result result = abs(X + p1*D) result abs(X + p1*D) abs X + p1*D X p1*D p1 D p1 = lo p1 lo rem1 = K - p1 rem1 K - p1 K p1 if (rem1%2 == 1):
			result = min((result, abs(X + p1*D + D), abs(X + p1*D - D)))
		 rem1%2 == 1 rem1%2 rem1 2 1 result = min((result, abs(X + p1*D + D), abs(X + p1*D - D))) result min((result, abs(X + p1*D + D), abs(X + p1*D - D))) min (result, abs(X + p1*D + D), abs(X + p1*D - D)) result abs(X + p1*D + D) abs X + p1*D + D X + p1*D X p1*D p1 D D abs(X + p1*D - D) abs X + p1*D - D X + p1*D X p1*D p1 D D p2 = lo - 1 p2 lo - 1 lo 1 rem2 = K - p2 rem2 K - p2 K p2 if (rem2%2 == 1):
			result = min((result, abs(X + p2*D + D), abs(X + p2*D - D)))
	 rem2%2 == 1 rem2%2 rem2 2 1 result = min((result, abs(X + p2*D + D), abs(X + p2*D - D))) result min((result, abs(X + p2*D + D), abs(X + p2*D - D))) min (result, abs(X + p2*D + D), abs(X + p2*D - D)) result abs(X + p2*D + D) abs X + p2*D + D X + p2*D X p2*D p2 D D abs(X + p2*D - D) abs X + p2*D - D X + p2*D X p2*D p2 D D print(result) print result elif (X > 0):
	lo, hi = 0, K
	while (lo < hi):
		mid = int(lo+ (hi - lo) / 2)
		if (X - mid*D <= 0):
			hi = mid;
		else:
			lo = mid + 1
	if (X - hi*D > 0):
		p1 = hi;
		if (abs(X - p1*D) < result):
			result = abs(X - p1*D)
	else:
		p1 = lo
		rem1 = K - p1
		if (rem1%2 == 1):
			result = min((result, abs(X - p1*D - D), abs(X - p1*D + D)))
		p2 = lo - 1;
		rem2 = K - p2
		if (rem2%2 == 1):
			result = min((result, abs(X - p2*D - D), abs(X - p2*D + D)))
	print(result) X > 0 X 0 lo, hi = 0, K lo 0 hi K while (lo < hi):
		mid = int(lo+ (hi - lo) / 2)
		if (X - mid*D <= 0):
			hi = mid;
		else:
			lo = mid + 1
	 lo < hi lo hi mid = int(lo+ (hi - lo) / 2) mid int(lo+ (hi - lo) / 2) int lo+ (hi - lo) / 2 lo (hi - lo) / 2 hi - lo hi lo 2 if (X - mid*D <= 0):
			hi = mid;
		else:
			lo = mid + 1
	 X - mid*D <= 0 X - mid*D X mid*D mid D 0 hi = mid hi mid lo = mid + 1 lo mid + 1 mid 1 if (X - hi*D > 0):
		p1 = hi;
		if (abs(X - p1*D) < result):
			result = abs(X - p1*D)
	else:
		p1 = lo
		rem1 = K - p1
		if (rem1%2 == 1):
			result = min((result, abs(X - p1*D - D), abs(X - p1*D + D)))
		p2 = lo - 1;
		rem2 = K - p2
		if (rem2%2 == 1):
			result = min((result, abs(X - p2*D - D), abs(X - p2*D + D)))
	 X - hi*D > 0 X - hi*D X hi*D hi D 0 p1 = hi p1 hi if (abs(X - p1*D) < result):
			result = abs(X - p1*D)
	 abs(X - p1*D) < result abs(X - p1*D) abs X - p1*D X p1*D p1 D result result = abs(X - p1*D) result abs(X - p1*D) abs X - p1*D X p1*D p1 D p1 = lo p1 lo rem1 = K - p1 rem1 K - p1 K p1 if (rem1%2 == 1):
			result = min((result, abs(X - p1*D - D), abs(X - p1*D + D)))
		 rem1%2 == 1 rem1%2 rem1 2 1 result = min((result, abs(X - p1*D - D), abs(X - p1*D + D))) result min((result, abs(X - p1*D - D), abs(X - p1*D + D))) min (result, abs(X - p1*D - D), abs(X - p1*D + D)) result abs(X - p1*D - D) abs X - p1*D - D X - p1*D X p1*D p1 D D abs(X - p1*D + D) abs X - p1*D + D X - p1*D X p1*D p1 D D p2 = lo - 1 p2 lo - 1 lo 1 rem2 = K - p2 rem2 K - p2 K p2 if (rem2%2 == 1):
			result = min((result, abs(X - p2*D - D), abs(X - p2*D + D)))
	 rem2%2 == 1 rem2%2 rem2 2 1 result = min((result, abs(X - p2*D - D), abs(X - p2*D + D))) result min((result, abs(X - p2*D - D), abs(X - p2*D + D))) min (result, abs(X - p2*D - D), abs(X - p2*D + D)) result abs(X - p2*D - D) abs X - p2*D - D X - p2*D X p2*D p2 D D abs(X - p2*D + D) abs X - p2*D + D X - p2*D X p2*D p2 D D print(result) print result if (K%2 == 1):
		print(D)
	else:
		print(0) K%2 == 1 K%2 K 2 1 print(D) print D print(0) print 0 p1 = lo lo p1 result = min((result, abs(X + p2*D + D), abs(X + p2*D - D))) min((result, abs(X + p2*D + D), abs(X + p2*D - D))) result result = 2e50 2e50 result hi = mid mid hi lo, hi = 0, K 0 lo hi = mid mid hi rem2 = K - p2 K - p2 rem2 lo, hi = 0, K 0 lo result = min((result, abs(X + p1*D + D), abs(X + p1*D - D))) min((result, abs(X + p1*D + D), abs(X + p1*D - D))) result result = min((result, abs(X - p2*D - D), abs(X - p2*D + D))) min((result, abs(X - p2*D - D), abs(X - p2*D + D))) result p1 = lo lo p1 lo = mid + 1 mid + 1 lo rem1 = K - p1 K - p1 rem1 lo = mid + 1 mid + 1 lo rem1 = K - p1 K - p1 rem1 X, K, D = map(int, input().split()) map(int, input().split()) X p2 = lo - 1 lo - 1 p2 D = map(int, input().split()) map(int, input().split()) D mid = int(lo+ (hi - lo) / 2) int(lo+ (hi - lo) / 2) mid p1 = hi hi p1 hi = 0, K K hi result = abs(X - p1*D) abs(X - p1*D) result hi = 0, K K hi K, D = map(int, input().split()) map(int, input().split()) K p1 = hi hi p1 p2 = lo - 1 lo - 1 p2 result = abs(X + p1*D) abs(X + p1*D) result result = min((result, abs(X - p1*D - D), abs(X - p1*D + D))) min((result, abs(X - p1*D - D), abs(X - p1*D + D))) result mid = int(lo+ (hi - lo) / 2) int(lo+ (hi - lo) / 2) mid rem2 = K - p2 K - p2 rem2
result = 2e50
X, K, D = map(int, input().split())

if (X < 0):
	lo, hi = 0, K
	while (lo < hi):
		mid = int(lo+ (hi - lo) / 2)
		if (X + mid*D >= 0):
			hi = mid;
		else:
			lo = mid + 1;
	if (X + hi*D < 0):
		p1 = hi
		if (abs(X + p1*D) < result):
			result = abs(X + p1*D)
	else:
		p1 = lo
		rem1 = K - p1
		if (rem1%2 == 1):
			result = min((result, abs(X + p1*D + D), abs(X + p1*D - D)))
		p2 = lo - 1
		rem2 = K - p2
		if (rem2%2 == 1):
			result = min((result, abs(X + p2*D + D), abs(X + p2*D - D)))
	print(result)
elif (X > 0):
	lo, hi = 0, K
	while (lo < hi):
		mid = int(lo+ (hi - lo) / 2)
		if (X - mid*D <= 0):
			hi = mid;
		else:
			lo = mid + 1
	if (X - hi*D > 0):
		p1 = hi;
		if (abs(X - p1*D) < result):
			result = abs(X - p1*D)
	else:
		p1 = lo
		rem1 = K - p1
		if (rem1%2 == 1):
			result = min((result, abs(X - p1*D - D), abs(X - p1*D + D)))
		p2 = lo - 1;
		rem2 = K - p2
		if (rem2%2 == 1):
			result = min((result, abs(X - p2*D - D), abs(X - p2*D + D)))
	print(result)
else:
	if (K%2 == 1):
		print(D)
	else:
		print(0)
