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

min_p = abs(x)//d
min_n = min_p + 1
rest_p = abs(x)- d*min_p
rest_n = rest_p - d

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

min_p = abs(x)//d
min_n = min_p + 1
rest_p = abs(x)- d*min_p
rest_n = rest_p - d

if k < min_p:
  print(abs(x) - k*d)
elif (k-min_p) % 2 == 0:
  print(rest_p)
else:
  print(abs(rest_n))
    

