x, k, d = map(int, input().split())
if (x - k*d > 0 and x > 0) or (x + k*d < 0 and x < 0):
    print(abs(x) - k*d )
else:
    if x % d == 0:
        if ((x/d) % 2) == (k % 2):
            print(0)
        else:
            print(d)
    else:
        y = abs(x)
        if (y % d < d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2) or (y % d > d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2):
            print(y % d)
        else:
            print(d - (y % d)) x, k, d = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split k d if (x - k*d > 0 and x > 0) or (x + k*d < 0 and x < 0):
    print(abs(x) - k*d )
else:
    if x % d == 0:
        if ((x/d) % 2) == (k % 2):
            print(0)
        else:
            print(d)
    else:
        y = abs(x)
        if (y % d < d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2) or (y % d > d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2):
            print(y % d)
        else:
            print(d - (y % d)) (x - k*d > 0 and x > 0) or (x + k*d < 0 and x < 0) x - k*d > 0 and x > 0 x - k*d > 0 x - k*d x k*d k d 0 x > 0 x 0 x + k*d < 0 and x < 0 x + k*d < 0 x + k*d x k*d k d 0 x < 0 x 0 print(abs(x) - k*d ) print abs(x) - k*d abs(x) abs x k*d k d if x % d == 0:
        if ((x/d) % 2) == (k % 2):
            print(0)
        else:
            print(d)
    else:
        y = abs(x)
        if (y % d < d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2) or (y % d > d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2):
            print(y % d)
        else:
            print(d - (y % d)) x % d == 0 x % d x d 0 if ((x/d) % 2) == (k % 2):
            print(0)
        else:
            print(d)
     ((x/d) % 2) == (k % 2) (x/d) % 2 x/d x d 2 k % 2 k 2 print(0) print 0 print(d) print d y = abs(x) y abs(x) abs x if (y % d < d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2) or (y % d > d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2):
            print(y % d)
        else:
            print(d - (y % d)) (y % d < d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2) or (y % d > d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2) y % d < d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2 y % d < d - (y % d) y % d y d d - (y % d) d y % d y d ((y - (y % d)) / d) % 2 == k % 2 ((y - (y % d)) / d) % 2 (y - (y % d)) / d y - (y % d) y y % d y d d 2 k % 2 k 2 y % d > d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2 y % d > d - (y % d) y % d y d d - (y % d) d y % d y d ((y - (y % d)) / d) % 2 == k % 2 ((y - (y % d)) / d) % 2 (y - (y % d)) / d y - (y % d) y y % d y d d 2 k % 2 k 2 print(y % d) print y % d y d print(d - (y % d)) print d - (y % d) d y % d y d d = map(int, input().split()) map(int, input().split()) d k, d = map(int, input().split()) map(int, input().split()) k y = abs(x) abs(x) y x, k, d = map(int, input().split()) map(int, input().split()) x
x, k, d = map(int, input().split())
if (x - k*d > 0 and x > 0) or (x + k*d < 0 and x < 0):
    print(abs(x) - k*d )
else:
    if x % d == 0:
        if ((x/d) % 2) == (k % 2):
            print(0)
        else:
            print(d)
    else:
        y = abs(x)
        if (y % d < d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2) or (y % d > d - (y % d) and ((y - (y % d)) / d) % 2 == k % 2):
            print(y % d)
        else:
            print(d - (y % d))