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