X, K, D = map(int,  input().split())
X = abs(X)
if K%2 == 1:
  K -= 1
  X -= D
  
K_ = K // 2

min_Y = X - K_ * (2 * D)

if min_Y > 0:
  print(min_Y)
else:
  min_Y_p = X % (2 * D)
  min_Y_m = 2 * D - X % (2 * D)
  print(min(min_Y_p, min_Y_m )) X, K, D = map(int,  input().split()) X map(int,  input().split()) map int input().split() ().split () input split K D X = abs(X) X abs(X) abs X if K%2 == 1:
  K -= 1
  X -= D
   K%2 == 1 K%2 K 2 1 K -= 1 K 1 X -= D X D K_ = K // 2 K_ K // 2 K 2 min_Y = X - K_ * (2 * D) min_Y X - K_ * (2 * D) X K_ * (2 * D) K_ 2 * D 2 D if min_Y > 0:
  print(min_Y)
else:
  min_Y_p = X % (2 * D)
  min_Y_m = 2 * D - X % (2 * D)
  print(min(min_Y_p, min_Y_m )) min_Y > 0 min_Y 0 print(min_Y) print min_Y min_Y_p = X % (2 * D) min_Y_p X % (2 * D) X 2 * D 2 D min_Y_m = 2 * D - X % (2 * D) min_Y_m 2 * D - X % (2 * D) 2 * D 2 D X % (2 * D) X 2 * D 2 D print(min(min_Y_p, min_Y_m )) print min(min_Y_p, min_Y_m ) min min_Y_p min_Y_m X -= D D X K_ = K // 2 K // 2 K_ min_Y = X - K_ * (2 * D) X - K_ * (2 * D) min_Y min_Y_m = 2 * D - X % (2 * D) 2 * D - X % (2 * D) min_Y_m X, K, D = map(int,  input().split()) map(int,  input().split()) X D = map(int,  input().split()) map(int,  input().split()) D X = abs(X) abs(X) X K, D = map(int,  input().split()) map(int,  input().split()) K K -= 1 1 K min_Y_p = X % (2 * D) X % (2 * D) min_Y_p
X, K, D = map(int,  input().split())
X = abs(X)
if K%2 == 1:
  K -= 1
  X -= D
  
K_ = K // 2

min_Y = X - K_ * (2 * D)

if min_Y > 0:
  print(min_Y)
else:
  min_Y_p = X % (2 * D)
  min_Y_m = 2 * D - X % (2 * D)
  print(min(min_Y_p, min_Y_m ))