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

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

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

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

print(ans)