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

t = min(abs(x)//d, k)
u = abs(x)-d*t
print(abs(u-d*((k-t)%2))) x, k, d = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split k d t = min(abs(x)//d, k) t min(abs(x)//d, k) min abs(x)//d abs(x) abs x d k u = abs(x)-d*t u abs(x)-d*t abs(x) abs x d*t d t print(abs(u-d*((k-t)%2))) print abs(u-d*((k-t)%2)) abs u-d*((k-t)%2) u d*((k-t)%2) d (k-t)%2 k-t k t 2 d = map(int, input().split()) map(int, input().split()) d k, d = map(int, input().split()) map(int, input().split()) k x, k, d = map(int, input().split()) map(int, input().split()) x u = abs(x)-d*t abs(x)-d*t u t = min(abs(x)//d, k) min(abs(x)//d, k) t
x, k, d = map(int, input().split())

t = min(abs(x)//d, k)
u = abs(x)-d*t
print(abs(u-d*((k-t)%2)))
