x,k,d=map(int,input().split())
x=abs(x)
q=x//d
if (k-q < 0):
    print(x-d*k)
elif (k-q) % 2 == 0:
    print(x-d*q)
else:
    print(d*(1+q)-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 q=x//d q x//d x d if (k-q < 0):
    print(x-d*k)
elif (k-q) % 2 == 0:
    print(x-d*q)
else:
    print(d*(1+q)-x) k-q < 0 k-q k q 0 print(x-d*k) print x-d*k x d*k d k elif (k-q) % 2 == 0:
    print(x-d*q) (k-q) % 2 == 0 (k-q) % 2 k-q k q 2 0 print(x-d*q) print x-d*q x d*q d q print(d*(1+q)-x) print d*(1+q)-x d*(1+q) d 1+q 1 q x k,d=map(int,input().split()) map(int,input().split()) k q=x//d x//d q x=abs(x) abs(x) x x,k,d=map(int,input().split()) map(int,input().split()) x d=map(int,input().split()) map(int,input().split()) d
x,k,d=map(int,input().split())
x=abs(x)
q=x//d
if (k-q < 0):
    print(x-d*k)
elif (k-q) % 2 == 0:
    print(x-d*q)
else:
    print(d*(1+q)-x)