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



tmp = abs(x) % d

cal = abs(x) // d

if tmp > abs(tmp - d):

    cal += 1

    tmp = abs(tmp - d)



if cal == k:

    print(tmp)

elif cal > k:

    print((abs(x) - k*d))

else:

    if (k - cal) % 2 == 0:

        print(tmp)

    else:

        print((min(abs(tmp-d),abs(tmp+d))))
x,k,d = list(map(int,input().split()))



ans = abs(x) % d

cal = abs(x) // d

if ans > abs(ans - d):

    cal += 1

    ans = abs(ans - d)



if cal > k:

    ans = abs(x) - k*d

else:

    if (k - cal) % 2 == 1:

        ans = min(abs(ans-d),abs(ans+d))



print(ans)
x, k, d = list(map(int, input().split()))
tmp = abs(x) % d
cal = abs(x) // d
if tmp > abs(tmp - d):
    cal += 1
    tmp = abs(tmp - d)
if cal == k:
    print(tmp)
elif cal > k:
    print((abs(x) - k * d))
else:
    if (k - cal) % 2 == 0:
        print(tmp)
    else:
        print((min(abs(tmp - d), abs(tmp + d))))

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

-tmp = abs(x) % d +ans = abs(x) % d -if tmp > abs(tmp - d): +if ans > abs(ans - d): -    tmp = abs(tmp - d) -if cal == k: -    print(tmp) -elif cal > k: -    print((abs(x) - k * d)) +    ans = abs(ans - d) +if cal > k: +    ans = abs(x) - k * d -    if (k - cal) % 2 == 0: -        print(tmp) -    else: -        print((min(abs(tmp - d), abs(tmp + d)))) +    if (k - cal) % 2 == 1: +        ans = min(abs(ans - d), abs(ans + d)) +print(ans)