x, k, d = map(int, input().split())

def sgn(x):
  if x > 0:
    return 1
  if x < 0:
    return -1
  return 0

if x > 0:
  x1 = x - k * d
else:
  x1 = x + k * d

if sgn(x) == sgn(x1):
  print(abs(x1))
  exit()
  
xright = x % d
xleft = x % d - d
#0目前
xr = (abs(x - xright) // d) % 2
if k % 2 == xr:
  print(abs(xright))
elif k % 2 != xr:
  print(abs(xleft)) x, k, d = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split k d def sgn(x):
  if x > 0:
    return 1
  if x < 0:
    return -1
  return 0 sgn if x > 0:
    return 1
   x > 0 x 0 return 1 1 if x < 0:
    return -1
   x < 0 x 0 return -1 -1 return 0 0 x x if x > 0:
  x1 = x - k * d
else:
  x1 = x + k * d x > 0 x 0 x1 = x - k * d x1 x - k * d x k * d k d x1 = x + k * d x1 x + k * d x k * d k d if sgn(x) == sgn(x1):
  print(abs(x1))
  exit()
   sgn(x) == sgn(x1) sgn(x) sgn x sgn(x1) sgn x1 print(abs(x1)) print abs(x1) abs x1 exit() exit xright = x % d xright x % d x d xleft = x % d - d xleft x % d - d x % d x d d xr = (abs(x - xright) // d) % 2 xr (abs(x - xright) // d) % 2 abs(x - xright) // d abs(x - xright) abs x - xright x xright d 2 if k % 2 == xr:
  print(abs(xright))
elif k % 2 != xr:
  print(abs(xleft)) k % 2 == xr k % 2 k 2 xr print(abs(xright)) print abs(xright) abs xright elif k % 2 != xr:
  print(abs(xleft)) k % 2 != xr k % 2 k 2 xr print(abs(xleft)) print abs(xleft) abs xleft xr = (abs(x - xright) // d) % 2 (abs(x - xright) // d) % 2 xr def sgn(x):
  if x > 0:
    return 1
  if x < 0:
    return -1
  return 0 def sgn(x):
  if x > 0:
    return 1
  if x < 0:
    return -1
  return 0 sgn x1 = x + k * d x + k * d x1 x, k, d = map(int, input().split()) map(int, input().split()) x k, d = map(int, input().split()) map(int, input().split()) k xright = x % d x % d xright xleft = x % d - d x % d - d xleft d = map(int, input().split()) map(int, input().split()) d x1 = x - k * d x - k * d x1
x, k, d = map(int, input().split())

def sgn(x):
  if x > 0:
    return 1
  if x < 0:
    return -1
  return 0

if x > 0:
  x1 = x - k * d
else:
  x1 = x + k * d

if sgn(x) == sgn(x1):
  print(abs(x1))
  exit()
  
xright = x % d
xleft = x % d - d
#0目前
xr = (abs(x - xright) // d) % 2
if k % 2 == xr:
  print(abs(xright))
elif k % 2 != xr:
  print(abs(xleft))