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

if x+d >=k*d:
    print(abs(x-k*d))
    exit()

if k%2==1:
    x=x-d

kaisu=int(x/(2*d))
ans=abs(x-kaisu*d*2)
if ans >=d:
    ans=2*d-ans

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

if x+d >=k*d:
    print(abs(x-k*d))
    exit()

if k%2==1:
    x=x-d

kaisu=int(x/(2*d))
ans=abs(x-kaisu*d*2)
if ans >=d:
    ans=2*d-ans

print(ans)