x,k,d = list(map(int, input().split()))
x = abs(x)
a,b = divmod(x, d)
a = min(a, k)
x -= a * d
#print('a=',a)
#print('x=',x)
#print('ka=',k-a)
x -= d * ((k-a) % 2)
print(abs(x)) x,k,d = list(map(int, input().split())) x list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split k d x = abs(x) x abs(x) abs x a,b = divmod(x, d) a divmod(x, d) divmod x d b a = min(a, k) a min(a, k) min a k x -= a * d x a * d a d x -= d * ((k-a) % 2) x d * ((k-a) % 2) d (k-a) % 2 k-a k a 2 print(abs(x)) print abs(x) abs x x -= a * d a * d x d = list(map(int, input().split())) list(map(int, input().split())) d b = divmod(x, d) divmod(x, d) b a = min(a, k) min(a, k) a x,k,d = list(map(int, input().split())) list(map(int, input().split())) x x = abs(x) abs(x) x x -= d * ((k-a) % 2) d * ((k-a) % 2) x a,b = divmod(x, d) divmod(x, d) a k,d = list(map(int, input().split())) list(map(int, input().split())) k
x,k,d = list(map(int, input().split()))
x = abs(x)
a,b = divmod(x, d)
a = min(a, k)
x -= a * d
#print('a=',a)
#print('x=',x)
#print('ka=',k-a)
x -= d * ((k-a) % 2)
print(abs(x))
