def main():

	X, K, D = list(map(int, input().split()))



	if abs(X) > K * D:

		print((abs(X) - K * D))

	elif abs(X) <= K * D:

		s = abs(X) // D

		if abs(X) % D == 0:

			if s % 2 == 0 and K % 2 == 0:

				print((0))

			elif s % 2 == 0 and K % 2 == 1:

				print(D)

			elif s % 2 == 1 and K % 2 == 0:

				print(D)

			elif s % 2 == 1 and K % 2 == 1:

				print((0))

		else:

			if s % 2 == 0 and K % 2 == 0:

				print((abs(X) - s * D))

			elif s % 2 == 0 and K % 2 == 1:

				print((abs(abs(X) - s * D - D)))

			elif s % 2 == 1 and K % 2 == 0:

				print((abs(abs(X) - s * D - D)))

			elif s % 2 == 1 and K % 2 == 1:

				print((abs(X) - s * D))

			



 

if __name__ == "__main__":

  	main()
def main():

	X, K, D = list(map(int, input().split()))



	ans = 0



	if abs(X) >= K * D: # 0にたどり着かない or ちょうど0にたどり着く

		ans = abs(X) - K * D

	else: # 0を通り過ぎて往復する

		s = abs(X) // D

		if (K - s) % 2 == 0:

			ans = abs(X) - s * D # abs(X) - s * D - 0

		else:

			ans = -abs(X) + (s + 1) * D # 0 - (abs(X) - (s + 1) * D)



	print(ans)



 

if __name__ == "__main__":

  	main()
def main():
    X, K, D = list(map(int, input().split()))
    if abs(X) > K * D:
        print((abs(X) - K * D))
    elif abs(X) <= K * D:
        s = abs(X) // D
        if abs(X) % D == 0:
            if s % 2 == 0 and K % 2 == 0:
                print((0))
            elif s % 2 == 0 and K % 2 == 1:
                print(D)
            elif s % 2 == 1 and K % 2 == 0:
                print(D)
            elif s % 2 == 1 and K % 2 == 1:
                print((0))
        else:
            if s % 2 == 0 and K % 2 == 0:
                print((abs(X) - s * D))
            elif s % 2 == 0 and K % 2 == 1:
                print((abs(abs(X) - s * D - D)))
            elif s % 2 == 1 and K % 2 == 0:
                print((abs(abs(X) - s * D - D)))
            elif s % 2 == 1 and K % 2 == 1:
                print((abs(X) - s * D))


if __name__ == "__main__":
    main()

def main():
    X, K, D = list(map(int, input().split()))
    ans = 0
    if abs(X) >= K * D:  # 0にたどり着かない or ちょうど0にたどり着く
        ans = abs(X) - K * D
    else:  # 0を通り過ぎて往復する
        s = abs(X) // D
        if (K - s) % 2 == 0:
            ans = abs(X) - s * D  # abs(X) - s * D - 0
        else:
            ans = -abs(X) + (s + 1) * D  # 0 - (abs(X) - (s + 1) * D)
    print(ans)


if __name__ == "__main__":
    main()

-    if abs(X) > K * D: -        print((abs(X) - K * D)) -    elif abs(X) <= K * D: +    ans = 0 +    if abs(X) >= K * D:  # 0にたどり着かない or ちょうど0にたどり着く +        ans = abs(X) - K * D +    else:  # 0を通り過ぎて往復する -        if abs(X) % D == 0: -            if s % 2 == 0 and K % 2 == 0: -                print((0)) -            elif s % 2 == 0 and K % 2 == 1: -                print(D) -            elif s % 2 == 1 and K % 2 == 0: -                print(D) -            elif s % 2 == 1 and K % 2 == 1: -                print((0)) +        if (K - s) % 2 == 0: +            ans = abs(X) - s * D  # abs(X) - s * D - 0 -            if s % 2 == 0 and K % 2 == 0: -                print((abs(X) - s * D)) -            elif s % 2 == 0 and K % 2 == 1: -                print((abs(abs(X) - s * D - D))) -            elif s % 2 == 1 and K % 2 == 0: -                print((abs(abs(X) - s * D - D))) -            elif s % 2 == 1 and K % 2 == 1: -                print((abs(X) - s * D)) +            ans = -abs(X) + (s + 1) * D  # 0 - (abs(X) - (s + 1) * D) +    print(ans)