y, k, d = map(int, input().split())
x = abs(y)
i = int(x / d)
if i >= k:
    p = x - k * d
elif i == x / d:
    if (i + k) % 2 == 0:
        p = 0
    else:
        p = d
else:
    if ((2 * i + 1) * d == 2 * x) or ((i + k) % 2 == 0):
        p = x - i * d
    else:
        p = (i + 1) * d - x
print(int(p)) 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 i = int(x / d) i int(x / d) int x / d x d if i >= k:
    p = x - k * d
elif i == x / d:
    if (i + k) % 2 == 0:
        p = 0
    else:
        p = d
else:
    if ((2 * i + 1) * d == 2 * x) or ((i + k) % 2 == 0):
        p = x - i * d
    else:
        p = (i + 1) * d - x i >= k i k p = x - k * d p x - k * d x k * d k d elif i == x / d:
    if (i + k) % 2 == 0:
        p = 0
    else:
        p = d i == x / d i x / d x d if (i + k) % 2 == 0:
        p = 0
    else:
        p = d (i + k) % 2 == 0 (i + k) % 2 i + k i k 2 0 p = 0 p 0 p = d p d if ((2 * i + 1) * d == 2 * x) or ((i + k) % 2 == 0):
        p = x - i * d
    else:
        p = (i + 1) * d - x ((2 * i + 1) * d == 2 * x) or ((i + k) % 2 == 0) (2 * i + 1) * d == 2 * x (2 * i + 1) * d 2 * i + 1 2 * i 2 i 1 d 2 * x 2 x (i + k) % 2 == 0 (i + k) % 2 i + k i k 2 0 p = x - i * d p x - i * d x i * d i d p = (i + 1) * d - x p (i + 1) * d - x (i + 1) * d i + 1 i 1 d x print(int(p)) print int(p) int p k, d = map(int, input().split()) map(int, input().split()) k p = (i + 1) * d - x (i + 1) * d - x p i = int(x / d) int(x / d) i p = x - i * d x - i * d p x = abs(y) abs(y) x y, k, d = map(int, input().split()) map(int, input().split()) y d = map(int, input().split()) map(int, input().split()) d p = d d p p = 0 0 p p = x - k * d x - k * d p
y, k, d = map(int, input().split())
x = abs(y)
i = int(x / d)
if i >= k:
    p = x - k * d
elif i == x / d:
    if (i + k) % 2 == 0:
        p = 0
    else:
        p = d
else:
    if ((2 * i + 1) * d == 2 * x) or ((i + k) % 2 == 0):
        p = x - i * d
    else:
        p = (i + 1) * d - x
print(int(p))