x,k,d=map(int,input().split())
b,c=abs(x%d),abs(-x%d)
mi=min(b,c)
if b<=c:
    a=abs(x//d)
else:
    a=abs(-x//d)
if k<a:
    print(min(abs(x-k*d),abs(x+k*d)))
else:
    if a%2==k%2:
        print(mi)
    else:
        print(min(abs(mi-d),abs(mi+d))) x,k,d=map(int,input().split()) x map(int,input().split()) map int input().split() ().split () input split k d b,c=abs(x%d),abs(-x%d) b abs(x%d) abs x%d x d c abs(-x%d) abs -x%d -x x d mi=min(b,c) mi min(b,c) min b c if b<=c:
    a=abs(x//d)
else:
    a=abs(-x//d) b<=c b c a=abs(x//d) a abs(x//d) abs x//d x d a=abs(-x//d) a abs(-x//d) abs -x//d -x x d if k<a:
    print(min(abs(x-k*d),abs(x+k*d)))
else:
    if a%2==k%2:
        print(mi)
    else:
        print(min(abs(mi-d),abs(mi+d))) k<a k a print(min(abs(x-k*d),abs(x+k*d))) print min(abs(x-k*d),abs(x+k*d)) min abs(x-k*d) abs x-k*d x k*d k d abs(x+k*d) abs x+k*d x k*d k d if a%2==k%2:
        print(mi)
    else:
        print(min(abs(mi-d),abs(mi+d))) a%2==k%2 a%2 a 2 k%2 k 2 print(mi) print mi print(min(abs(mi-d),abs(mi+d))) print min(abs(mi-d),abs(mi+d)) min abs(mi-d) abs mi-d mi d abs(mi+d) abs mi+d mi d mi=min(b,c) min(b,c) mi b,c=abs(x%d),abs(-x%d) abs(x%d) b k,d=map(int,input().split()) map(int,input().split()) k d=map(int,input().split()) map(int,input().split()) d a=abs(x//d) abs(x//d) a c=abs(x%d),abs(-x%d) abs(-x%d) c a=abs(-x//d) abs(-x//d) a x,k,d=map(int,input().split()) map(int,input().split()) x
x,k,d=map(int,input().split())
b,c=abs(x%d),abs(-x%d)
mi=min(b,c)
if b<=c:
    a=abs(x//d)
else:
    a=abs(-x//d)
if k<a:
    print(min(abs(x-k*d),abs(x+k*d)))
else:
    if a%2==k%2:
        print(mi)
    else:
        print(min(abs(mi-d),abs(mi+d)))
