X, K, D = map(int, input().split())
X = abs(X)
point = X % D
q = X // D
ans = 0
if q >= K:
    ans = abs(X-D*K)
elif (K - q) % 2 == 0:
    ans = point
else:
    ans = D-point
print(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 point = X % D point X % D X D q = X // D q X // D X D ans = 0 ans 0 if q >= K:
    ans = abs(X-D*K)
elif (K - q) % 2 == 0:
    ans = point
else:
    ans = D-point q >= K q K ans = abs(X-D*K) ans abs(X-D*K) abs X-D*K X D*K D K elif (K - q) % 2 == 0:
    ans = point (K - q) % 2 == 0 (K - q) % 2 K - q K q 2 0 ans = point ans point ans = D-point ans D-point D point print(ans) print ans D = map(int, input().split()) map(int, input().split()) D q = X // D X // D q ans = D-point D-point ans ans = abs(X-D*K) abs(X-D*K) ans K, D = map(int, input().split()) map(int, input().split()) K ans = 0 0 ans X = abs(X) abs(X) X point = X % D X % D point ans = point point ans X, K, D = map(int, input().split()) map(int, input().split()) X
X, K, D = map(int, input().split())
X = abs(X)
point = X % D
q = X // D
ans = 0
if q >= K:
    ans = abs(X-D*K)
elif (K - q) % 2 == 0:
    ans = point
else:
    ans = D-point
print(ans)