import sys
import math

X, K, D = [int(i) for i in input().split()]

x = (abs(X) - K * D)
if x >= 0:
  print(x)
  sys.exit()

a = X // D if X > 0 else math.ceil(X / D)
k = K - a
k = k % 2

print(abs(X - D * a - k * D if X > 0 else X - D * a + k * D)) import sys sys import math math int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i X, K, D = [int(i) for i in input().split()] X [int(i) for i in input().split()] K D x = (abs(X) - K * D) x abs(X) - K * D abs(X) abs X K * D K D if x >= 0:
  print(x)
  sys.exit() x >= 0 x 0 print(x) print x sys.exit() sys.exit sys exit a = X // D if X > 0 else math.ceil(X / D) a X // D if X > 0 else math.ceil(X / D) X > 0 X 0 X // D X D math.ceil(X / D) math.ceil math ceil X / D X D k = K - a k K - a K a k = k % 2 k k % 2 k 2 print(abs(X - D * a - k * D if X > 0 else X - D * a + k * D)) print abs(X - D * a - k * D if X > 0 else X - D * a + k * D) abs X - D * a - k * D if X > 0 else X - D * a + k * D X > 0 X 0 X - D * a - k * D X - D * a X D * a D a k * D k D X - D * a + k * D X - D * a X D * a D a k * D k D k = K - a K - a k a = X // D if X > 0 else math.ceil(X / D) X // D if X > 0 else math.ceil(X / D) a X, K, D = [int(i) for i in input().split()] [int(i) for i in input().split()] X k = k % 2 k % 2 k D = [int(i) for i in input().split()] [int(i) for i in input().split()] D K, D = [int(i) for i in input().split()] [int(i) for i in input().split()] K x = (abs(X) - K * D) abs(X) - K * D x
import sys
import math

X, K, D = [int(i) for i in input().split()]

x = (abs(X) - K * D)
if x >= 0:
  print(x)
  sys.exit()

a = X // D if X > 0 else math.ceil(X / D)
k = K - a
k = k % 2

print(abs(X - D * a - k * D if X > 0 else X - D * a + k * D))
