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

if k*d<=x:
  print(x-k*d)
else:
  e = math.floor(x/d)
  k -= e
  x = x-e*d
  if k%2 == 0:
    print(x)
  else:
    print(abs(x-d))
 import math math x,k,d = map(int,input().split()) x map(int,input().split()) map int input().split() ().split () input split k d d = abs(d) d abs(d) abs d x = abs(x) x abs(x) abs x if k*d<=x:
  print(x-k*d)
else:
  e = math.floor(x/d)
  k -= e
  x = x-e*d
  if k%2 == 0:
    print(x)
  else:
    print(abs(x-d)) k*d<=x k*d k d x print(x-k*d) print x-k*d x k*d k d e = math.floor(x/d) e math.floor(x/d) math.floor math floor x/d x d k -= e k e x = x-e*d x x-e*d x e*d e d if k%2 == 0:
    print(x)
  else:
    print(abs(x-d)) k%2 == 0 k%2 k 2 0 print(x) print x 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 = abs(x) abs(x) x x,k,d = map(int,input().split()) map(int,input().split()) x d = abs(d) abs(d) d e = math.floor(x/d) math.floor(x/d) e x = x-e*d x-e*d x k -= e e k
import math
x,k,d = map(int,input().split())
d = abs(d)
x = abs(x)

if k*d<=x:
  print(x-k*d)
else:
  e = math.floor(x/d)
  k -= e
  x = x-e*d
  if k%2 == 0:
    print(x)
  else:
    print(abs(x-d))

