x,k,d=list(map(int,input().split()))
#print(x,k,d)
result=abs(x)-k*d
swithn=0

if result<0:
    if k%2==1:
        x-=d
    result=min(x%(2*d),-x%(2*d))
print(result) x,k,d=list(map(int,input().split())) x list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split k d result=abs(x)-k*d result abs(x)-k*d abs(x) abs x k*d k d swithn=0 swithn 0 if result<0:
    if k%2==1:
        x-=d
    result=min(x%(2*d),-x%(2*d)) result<0 result 0 if k%2==1:
        x-=d
     k%2==1 k%2 k 2 1 x-=d x d result=min(x%(2*d),-x%(2*d)) result min(x%(2*d),-x%(2*d)) min x%(2*d) x 2*d 2 d -x%(2*d) -x x 2*d 2 d print(result) print result result=abs(x)-k*d abs(x)-k*d result result=min(x%(2*d),-x%(2*d)) min(x%(2*d),-x%(2*d)) result x,k,d=list(map(int,input().split())) list(map(int,input().split())) x swithn=0 0 swithn d=list(map(int,input().split())) list(map(int,input().split())) d x-=d d x k,d=list(map(int,input().split())) list(map(int,input().split())) k
x,k,d=list(map(int,input().split()))
#print(x,k,d)
result=abs(x)-k*d
swithn=0

if result<0:
    if k%2==1:
        x-=d
    result=min(x%(2*d),-x%(2*d))
print(result)