X, K, D = map(int, input().split())
ans = abs(abs(X) - D*K)

a = abs(X)//D
b = abs(X)%D
if (K - a)%2 == 1 and a < K:
    ans = D - b
elif (K - a)%2 == 0 and a < K:
    ans = b

print(ans) X, K, D = map(int, input().split()) X map(int, input().split()) map int input().split() ().split () input split K D ans = abs(abs(X) - D*K) ans abs(abs(X) - D*K) abs abs(X) - D*K abs(X) abs X D*K D K a = abs(X)//D a abs(X)//D abs(X) abs X D b = abs(X)%D b abs(X)%D abs(X) abs X D if (K - a)%2 == 1 and a < K:
    ans = D - b
elif (K - a)%2 == 0 and a < K:
    ans = b (K - a)%2 == 1 and a < K (K - a)%2 == 1 (K - a)%2 K - a K a 2 1 a < K a K ans = D - b ans D - b D b elif (K - a)%2 == 0 and a < K:
    ans = b (K - a)%2 == 0 and a < K (K - a)%2 == 0 (K - a)%2 K - a K a 2 0 a < K a K ans = b ans b print(ans) print ans X, K, D = map(int, input().split()) map(int, input().split()) X b = abs(X)%D abs(X)%D b K, D = map(int, input().split()) map(int, input().split()) K D = map(int, input().split()) map(int, input().split()) D ans = abs(abs(X) - D*K) abs(abs(X) - D*K) ans ans = b b ans ans = D - b D - b ans a = abs(X)//D abs(X)//D a
X, K, D = map(int, input().split())
ans = abs(abs(X) - D*K)

a = abs(X)//D
b = abs(X)%D
if (K - a)%2 == 1 and a < K:
    ans = D - b
elif (K - a)%2 == 0 and a < K:
    ans = b

print(ans)