x,k,d=[int(i) for i in input().strip().split(" ")]
#絶対値変換
x=abs(x) if x<0 else x
#減らすのみ
if x//d>=k:
    print(x-d*k)
else:
    if (k-x//d)%2==0:
        print(x%d)
    else:
        print(d-(x%d)) int(i) for i in input().strip().split(" ") for i in input().strip().split(" ") i input().strip().split(" ") ().strip().split ().strip() ().strip () input strip split " " for i in input().strip().split(" ") int(i) int i x,k,d=[int(i) for i in input().strip().split(" ")] x [int(i) for i in input().strip().split(" ")] k d x=abs(x) if x<0 else x x abs(x) if x<0 else x x<0 x 0 abs(x) abs x x if x//d>=k:
    print(x-d*k)
else:
    if (k-x//d)%2==0:
        print(x%d)
    else:
        print(d-(x%d)) x//d>=k x//d x d k print(x-d*k) print x-d*k x d*k d k if (k-x//d)%2==0:
        print(x%d)
    else:
        print(d-(x%d)) (k-x//d)%2==0 (k-x//d)%2 k-x//d k x//d x d 2 0 print(x%d) print x%d x d print(d-(x%d)) print d-(x%d) d x%d x d d=[int(i) for i in input().strip().split(" ")] [int(i) for i in input().strip().split(" ")] d x=abs(x) if x<0 else x abs(x) if x<0 else x x x,k,d=[int(i) for i in input().strip().split(" ")] [int(i) for i in input().strip().split(" ")] x k,d=[int(i) for i in input().strip().split(" ")] [int(i) for i in input().strip().split(" ")] k
x,k,d=[int(i) for i in input().strip().split(" ")]
#絶対値変換
x=abs(x) if x<0 else x
#減らすのみ
if x//d>=k:
    print(x-d*k)
else:
    if (k-x//d)%2==0:
        print(x%d)
    else:
        print(d-(x%d))