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



# print(x,k,d)



x = abs(x)

if x <= d:

    if k%2:

        print((d-x))

    else:

        print(x)

    exit()



c = min(x//d, k)

x -= d*c

k -= c

if k%2:

    print((abs(d-x)))

else:

    print(x)



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

x = abs(x)

if x > d:

    c = min(x//d, k)

    x -= d*c

    k -= c

if k%2: x = d - x

print(x)

x, k, d = list(map(int, input().split()))
# print(x,k,d)
x = abs(x)
if x <= d:
    if k % 2:
        print((d - x))
    else:
        print(x)
    exit()
c = min(x // d, k)
x -= d * c
k -= c
if k % 2:
    print((abs(d - x)))
else:
    print(x)

x, k, d = list(map(int, input().split()))
x = abs(x)
if x > d:
    c = min(x // d, k)
    x -= d * c
    k -= c
if k % 2:
    x = d - x
print(x)

-# print(x,k,d) -if x <= d: -    if k % 2: -        print((d - x)) -    else: -        print(x) -    exit() -c = min(x // d, k) -x -= d * c -k -= c +if x > d: +    c = min(x // d, k) +    x -= d * c +    k -= c -    print((abs(d - x))) -else: -    print(x) +    x = d - x +print(x)