x, k, d = map(int, input().split())
if x < 0:
  x *= -1
if x >= k * d:
  print(x - (k * d))
else:
  k -= x // d
  x = x % d
  if k % 2 == 0:
    if x < abs(x - (2 * d)):
      print(x)
    else:
      print(abs(x - 2 * d))
  else:
    if abs(x - d) < abs(x + d):
      print(abs(x - d))
    else:
      print(abs(x + d)) x, k, d = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split k d if x < 0:
  x *= -1 x < 0 x 0 x *= -1 x -1 if x >= k * d:
  print(x - (k * d))
else:
  k -= x // d
  x = x % d
  if k % 2 == 0:
    if x < abs(x - (2 * d)):
      print(x)
    else:
      print(abs(x - 2 * d))
  else:
    if abs(x - d) < abs(x + d):
      print(abs(x - d))
    else:
      print(abs(x + d)) x >= k * d x k * d k d print(x - (k * d)) print x - (k * d) x k * d k d k -= x // d k x // d x d x = x % d x x % d x d if k % 2 == 0:
    if x < abs(x - (2 * d)):
      print(x)
    else:
      print(abs(x - 2 * d))
  else:
    if abs(x - d) < abs(x + d):
      print(abs(x - d))
    else:
      print(abs(x + d)) k % 2 == 0 k % 2 k 2 0 if x < abs(x - (2 * d)):
      print(x)
    else:
      print(abs(x - 2 * d))
   x < abs(x - (2 * d)) x abs(x - (2 * d)) abs x - (2 * d) x 2 * d 2 d print(x) print x print(abs(x - 2 * d)) print abs(x - 2 * d) abs x - 2 * d x 2 * d 2 d if abs(x - d) < abs(x + d):
      print(abs(x - d))
    else:
      print(abs(x + d)) abs(x - d) < abs(x + d) abs(x - d) abs x - d x d abs(x + d) abs x + d x d print(abs(x - d)) print abs(x - d) abs x - d x d print(abs(x + d)) print abs(x + d) abs x + d x d d = map(int, input().split()) map(int, input().split()) d k, d = map(int, input().split()) map(int, input().split()) k x, k, d = map(int, input().split()) map(int, input().split()) x x *= -1 -1 x k -= x // d x // d k x = x % d x % d x
x, k, d = map(int, input().split())
if x < 0:
  x *= -1
if x >= k * d:
  print(x - (k * d))
else:
  k -= x // d
  x = x % d
  if k % 2 == 0:
    if x < abs(x - (2 * d)):
      print(x)
    else:
      print(abs(x - 2 * d))
  else:
    if abs(x - d) < abs(x + d):
      print(abs(x - d))
    else:
      print(abs(x + d))