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

m = x // d
p = k - m if m <= k else 0

if p == 0:
  print(x - (k*d))
else:
  x -= m * d
  if p & 1:
    print(abs(x - d))
  else:
    print(x) x, k, d = map(int,input().split()) x map(int,input().split()) map int input().split() ().split () input split k d x = abs(x) x abs(x) abs x m = x // d m x // d x d p = k - m if m <= k else 0 p k - m if m <= k else 0 m <= k m k k - m k m 0 if p == 0:
  print(x - (k*d))
else:
  x -= m * d
  if p & 1:
    print(abs(x - d))
  else:
    print(x) p == 0 p 0 print(x - (k*d)) print x - (k*d) x k*d k d x -= m * d x m * d m d if p & 1:
    print(abs(x - d))
  else:
    print(x) p & 1 p 1 print(abs(x - d)) print abs(x - d) abs x - d x d print(x) print x x, k, d = map(int,input().split()) map(int,input().split()) x x -= m * d m * d x k, d = map(int,input().split()) map(int,input().split()) k x = abs(x) abs(x) x d = map(int,input().split()) map(int,input().split()) d p = k - m if m <= k else 0 k - m if m <= k else 0 p m = x // d x // d m
x, k, d = map(int,input().split())
x = abs(x)

m = x // d
p = k - m if m <= k else 0

if p == 0:
  print(x - (k*d))
else:
  x -= m * d
  if p & 1:
    print(abs(x - d))
  else:
    print(x)