# C - Walking Takahashi

X, K, D = map(int, input().split())
X = abs(X)
d = X // D
m = X % D

if K <= d:
    ans = X - (D * K)
elif (K - d) % 2 == 0:
    ans = X - (D * d)
else:
    ans = X - (D * (d+1))
print(abs(ans)) 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 d = X // D d X // D X D m = X % D m X % D X D if K <= d:
    ans = X - (D * K)
elif (K - d) % 2 == 0:
    ans = X - (D * d)
else:
    ans = X - (D * (d+1)) K <= d K d ans = X - (D * K) ans X - (D * K) X D * K D K elif (K - d) % 2 == 0:
    ans = X - (D * d) (K - d) % 2 == 0 (K - d) % 2 K - d K d 2 0 ans = X - (D * d) ans X - (D * d) X D * d D d ans = X - (D * (d+1)) ans X - (D * (d+1)) X D * (d+1) D d+1 d 1 print(abs(ans)) print abs(ans) abs ans ans = X - (D * K) X - (D * K) ans X = abs(X) abs(X) X m = X % D X % D m K, D = map(int, input().split()) map(int, input().split()) K X, K, D = map(int, input().split()) map(int, input().split()) X ans = X - (D * (d+1)) X - (D * (d+1)) ans ans = X - (D * d) X - (D * d) ans D = map(int, input().split()) map(int, input().split()) D d = X // D X // D d
# C - Walking Takahashi

X, K, D = map(int, input().split())
X = abs(X)
d = X // D
m = X % D

if K <= d:
    ans = X - (D * K)
elif (K - d) % 2 == 0:
    ans = X - (D * d)
else:
    ans = X - (D * (d+1))
print(abs(ans))