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

if x < 0 :
  x = -x

l = x // D

if K > l:
  K = K - l
  if (K % 2) == 0:
    print(abs(x-D*l))
  else:
    print(abs(x-D*(l+1)))
else:
  print(abs(x - D*K)) 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 if x < 0 :
  x = -x x < 0 x 0 x = -x x -x x l = x // D l x // D x D if K > l:
  K = K - l
  if (K % 2) == 0:
    print(abs(x-D*l))
  else:
    print(abs(x-D*(l+1)))
else:
  print(abs(x - D*K)) K > l K l K = K - l K K - l K l if (K % 2) == 0:
    print(abs(x-D*l))
  else:
    print(abs(x-D*(l+1))) (K % 2) == 0 K % 2 K 2 0 print(abs(x-D*l)) print abs(x-D*l) abs x-D*l x D*l D l print(abs(x-D*(l+1))) print abs(x-D*(l+1)) abs x-D*(l+1) x D*(l+1) D l+1 l 1 print(abs(x - D*K)) print abs(x - D*K) abs x - D*K x D*K D K D = list(map(int, input().split())) list(map(int, input().split())) D K,D = list(map(int, input().split())) list(map(int, input().split())) K x = -x -x x l = x // D x // D l K = K - l K - l K x,K,D = list(map(int, input().split())) list(map(int, input().split())) x
x,K,D = list(map(int, input().split()))

if x < 0 :
  x = -x

l = x // D

if K > l:
  K = K - l
  if (K % 2) == 0:
    print(abs(x-D*l))
  else:
    print(abs(x-D*(l+1)))
else:
  print(abs(x - D*K))
