x,k,d = map(int,input().split())
x = abs(x)
r = x % d
q = x // d
if (k*d) < x:
    print(x - (k*d))
else:
    if (k - q) % 2 == 0:
        print(r)
    else:
        print(abs(d-r)) 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 r = x % d r x % d x d q = x // d q x // d x d if (k*d) < x:
    print(x - (k*d))
else:
    if (k - q) % 2 == 0:
        print(r)
    else:
        print(abs(d-r)) (k*d) < x k*d k d x print(x - (k*d)) print x - (k*d) x k*d k d if (k - q) % 2 == 0:
        print(r)
    else:
        print(abs(d-r)) (k - q) % 2 == 0 (k - q) % 2 k - q k q 2 0 print(r) print r print(abs(d-r)) print abs(d-r) abs d-r d r k,d = map(int,input().split()) map(int,input().split()) k r = x % d x % d r d = map(int,input().split()) map(int,input().split()) d x = abs(x) abs(x) x x,k,d = map(int,input().split()) map(int,input().split()) x q = x // d x // d q
x,k,d = map(int,input().split())
x = abs(x)
r = x % d
q = x // d
if (k*d) < x:
    print(x - (k*d))
else:
    if (k - q) % 2 == 0:
        print(r)
    else:
        print(abs(d-r))