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