x,k,d = [int(x) for x in input().split()]
if x < 0:
  x *= -1
def f():
  c = 0
  if x - (k * d) > 0:
    c = x - (k * d)
    return True
  return False

def check():
  l = 0
  r = k
  while l <= r:
    m = (r + l) // 2
    p = x - d * (2 * m - k)
    #print(l,m,r,p)
    if p > d:
      l = m + 1
    elif p < -1 * d:
      r = m - 1
    else:
      return m
  return m

if f():
  print(x - (k * d))
else:
  m1 = check()
  t = x - d * (2 * m1 - k)
  print(abs(t)) int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x x,k,d = [int(x) for x in input().split()] x [int(x) for x in input().split()] k d if x < 0:
  x *= -1 x < 0 x 0 x *= -1 x -1 def f():
  c = 0
  if x - (k * d) > 0:
    c = x - (k * d)
    return True
  return False f c = 0 c 0 if x - (k * d) > 0:
    c = x - (k * d)
    return True
   x - (k * d) > 0 x - (k * d) x k * d k d 0 c = x - (k * d) c x - (k * d) x k * d k d return True True return False False def check():
  l = 0
  r = k
  while l <= r:
    m = (r + l) // 2
    p = x - d * (2 * m - k)
    #print(l,m,r,p)
    if p > d:
      l = m + 1
    elif p < -1 * d:
      r = m - 1
    else:
      return m
  return m check l = 0 l 0 r = k r k while l <= r:
    m = (r + l) // 2
    p = x - d * (2 * m - k)
    #print(l,m,r,p)
    if p > d:
      l = m + 1
    elif p < -1 * d:
      r = m - 1
    else:
      return m
   l <= r l r m = (r + l) // 2 m (r + l) // 2 r + l r l 2 p = x - d * (2 * m - k) p x - d * (2 * m - k) x d * (2 * m - k) d 2 * m - k 2 * m 2 m k if p > d:
      l = m + 1
    elif p < -1 * d:
      r = m - 1
    else:
      return m
   p > d p d l = m + 1 l m + 1 m 1 elif p < -1 * d:
      r = m - 1
     p < -1 * d p -1 * d -1 d r = m - 1 r m - 1 m 1 return m m return m m if f():
  print(x - (k * d))
else:
  m1 = check()
  t = x - d * (2 * m1 - k)
  print(abs(t)) f() f print(x - (k * d)) print x - (k * d) x k * d k d m1 = check() m1 check() check t = x - d * (2 * m1 - k) t x - d * (2 * m1 - k) x d * (2 * m1 - k) d 2 * m1 - k 2 * m1 2 m1 k print(abs(t)) print abs(t) abs t x *= -1 -1 x d = [int(x) for x in input().split()] [int(x) for x in input().split()] d k,d = [int(x) for x in input().split()] [int(x) for x in input().split()] k t = x - d * (2 * m1 - k) x - d * (2 * m1 - k) t x,k,d = [int(x) for x in input().split()] [int(x) for x in input().split()] x m1 = check() check() m1 def f():
  c = 0
  if x - (k * d) > 0:
    c = x - (k * d)
    return True
  return False def f():
  c = 0
  if x - (k * d) > 0:
    c = x - (k * d)
    return True
  return False f def check():
  l = 0
  r = k
  while l <= r:
    m = (r + l) // 2
    p = x - d * (2 * m - k)
    #print(l,m,r,p)
    if p > d:
      l = m + 1
    elif p < -1 * d:
      r = m - 1
    else:
      return m
  return m def check():
  l = 0
  r = k
  while l <= r:
    m = (r + l) // 2
    p = x - d * (2 * m - k)
    #print(l,m,r,p)
    if p > d:
      l = m + 1
    elif p < -1 * d:
      r = m - 1
    else:
      return m
  return m check
x,k,d = [int(x) for x in input().split()]
if x < 0:
  x *= -1
def f():
  c = 0
  if x - (k * d) > 0:
    c = x - (k * d)
    return True
  return False

def check():
  l = 0
  r = k
  while l <= r:
    m = (r + l) // 2
    p = x - d * (2 * m - k)
    #print(l,m,r,p)
    if p > d:
      l = m + 1
    elif p < -1 * d:
      r = m - 1
    else:
      return m
  return m

if f():
  print(x - (k * d))
else:
  m1 = check()
  t = x - d * (2 * m1 - k)
  print(abs(t))
