n, k, d = map(int, input().split())
n = abs(n)
q = n // d
r = n % d
if q >= k:
  print(n - k*d)
else:
  if (k - q) % 2 == 0:
    print(r)
  else:
    print(d - r) n, k, d = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k d n = abs(n) n abs(n) abs n q = n // d q n // d n d r = n % d r n % d n d if q >= k:
  print(n - k*d)
else:
  if (k - q) % 2 == 0:
    print(r)
  else:
    print(d - r) q >= k q k print(n - k*d) print n - k*d n k*d k d if (k - q) % 2 == 0:
    print(r)
  else:
    print(d - r) (k - q) % 2 == 0 (k - q) % 2 k - q k q 2 0 print(r) print r print(d - r) print d - r d r n = abs(n) abs(n) n q = n // d n // d q n, k, d = map(int, input().split()) map(int, input().split()) n k, d = map(int, input().split()) map(int, input().split()) k r = n % d n % d r d = map(int, input().split()) map(int, input().split()) d
n, k, d = map(int, input().split())
n = abs(n)
q = n // d
r = n % d
if q >= k:
  print(n - k*d)
else:
  if (k - q) % 2 == 0:
    print(r)
  else:
    print(d - r)