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

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

if x%d==0:
    minNear  = x%d + d
    minFar = x%d
    minTransitionToNear = (x-minNear)/d
    #print(minNear)
    #print(minFar)
    #print(minTransitionToNear)
    
else:
    minNear  = x%d
    minFar = x%d - d
    minTransitionToNear = (x-minNear)/d
    #print(minNear)
    #print(minFar)
    #print(minTransitionToNear)
    
if k<minTransitionToNear:
    print(x-k*d)
else:
    if (k-minTransitionToNear)%2==0:
        print(abs(minNear))
    else:
        print(abs(minFar))