X, K, D = map(int, input().split())

ans = 0

if abs(X) > K*D:
    ans = abs(X) - K*D
else:
    k = abs(X)//D
    if (K-k)%2 == 0:
        ans = abs(X) - D*k
    else:
        ans = D - (abs(X) - D*k)

print(ans) X, K, D = map(int, input().split()) X map(int, input().split()) map int input().split() ().split () input split K D ans = 0 ans 0 if abs(X) > K*D:
    ans = abs(X) - K*D
else:
    k = abs(X)//D
    if (K-k)%2 == 0:
        ans = abs(X) - D*k
    else:
        ans = D - (abs(X) - D*k) abs(X) > K*D abs(X) abs X K*D K D ans = abs(X) - K*D ans abs(X) - K*D abs(X) abs X K*D K D k = abs(X)//D k abs(X)//D abs(X) abs X D if (K-k)%2 == 0:
        ans = abs(X) - D*k
    else:
        ans = D - (abs(X) - D*k) (K-k)%2 == 0 (K-k)%2 K-k K k 2 0 ans = abs(X) - D*k ans abs(X) - D*k abs(X) abs X D*k D k ans = D - (abs(X) - D*k) ans D - (abs(X) - D*k) D abs(X) - D*k abs(X) abs X D*k D k print(ans) print ans ans = abs(X) - K*D abs(X) - K*D ans K, D = map(int, input().split()) map(int, input().split()) K ans = D - (abs(X) - D*k) D - (abs(X) - D*k) ans k = abs(X)//D abs(X)//D k D = map(int, input().split()) map(int, input().split()) D ans = abs(X) - D*k abs(X) - D*k ans X, K, D = map(int, input().split()) map(int, input().split()) X ans = 0 0 ans
X, K, D = map(int, input().split())

ans = 0

if abs(X) > K*D:
    ans = abs(X) - K*D
else:
    k = abs(X)//D
    if (K-k)%2 == 0:
        ans = abs(X) - D*k
    else:
        ans = D - (abs(X) - D*k)

print(ans)