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