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

zan = X%D


K2 = K-X//D
if K2 < 0:
  print(X-D*K)
else:
  if K2%2 == 0:
  	print(zan)
  else:
  	print(D-zan) X, K, D = list(map(int, input().split())) X list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split K D X = abs(X) X abs(X) abs X zan = X%D zan X%D X D K2 = K-X//D K2 K-X//D K X//D X D if K2 < 0:
  print(X-D*K)
else:
  if K2%2 == 0:
  	print(zan)
  else:
  	print(D-zan) K2 < 0 K2 0 print(X-D*K) print X-D*K X D*K D K if K2%2 == 0:
  	print(zan)
  else:
  	print(D-zan) K2%2 == 0 K2%2 K2 2 0 print(zan) print zan print(D-zan) print D-zan D zan D = list(map(int, input().split())) list(map(int, input().split())) D X = abs(X) abs(X) X zan = X%D X%D zan X, K, D = list(map(int, input().split())) list(map(int, input().split())) X K2 = K-X//D K-X//D K2 K, D = list(map(int, input().split())) list(map(int, input().split())) K
X, K, D = list(map(int, input().split()))
X = abs(X)

zan = X%D


K2 = K-X//D
if K2 < 0:
  print(X-D*K)
else:
  if K2%2 == 0:
  	print(zan)
  else:
  	print(D-zan)