X, K, D = (int(x) for x in input().split())

if X > 0:
    div, mod = divmod(X, D)
    if div >= K:
        answer = X - K*D
    else:
        if (K - div)%2 == 0:
            answer = X - div*D
        else:
            answer = abs(X - (div+1)*D)
elif X < 0:
    div, mod = divmod(-X, D)
    if div >= K:
        answer = abs(X + K*D)
    else:
        if (K - div)%2 == 0:
            answer = abs(X + div*D)
        else:
            answer = X + (div+1)*D
else:
    if K%2 == 0:
        answer = 0
    else:
        answer = D

print(answer) int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x X, K, D = (int(x) for x in input().split()) X (int(x) for x in input().split()) K D if X > 0:
    div, mod = divmod(X, D)
    if div >= K:
        answer = X - K*D
    else:
        if (K - div)%2 == 0:
            answer = X - div*D
        else:
            answer = abs(X - (div+1)*D)
elif X < 0:
    div, mod = divmod(-X, D)
    if div >= K:
        answer = abs(X + K*D)
    else:
        if (K - div)%2 == 0:
            answer = abs(X + div*D)
        else:
            answer = X + (div+1)*D
else:
    if K%2 == 0:
        answer = 0
    else:
        answer = D X > 0 X 0 div, mod = divmod(X, D) div divmod(X, D) divmod X D mod if div >= K:
        answer = X - K*D
    else:
        if (K - div)%2 == 0:
            answer = X - div*D
        else:
            answer = abs(X - (div+1)*D) div >= K div K answer = X - K*D answer X - K*D X K*D K D if (K - div)%2 == 0:
            answer = X - div*D
        else:
            answer = abs(X - (div+1)*D) (K - div)%2 == 0 (K - div)%2 K - div K div 2 0 answer = X - div*D answer X - div*D X div*D div D answer = abs(X - (div+1)*D) answer abs(X - (div+1)*D) abs X - (div+1)*D X (div+1)*D div+1 div 1 D elif X < 0:
    div, mod = divmod(-X, D)
    if div >= K:
        answer = abs(X + K*D)
    else:
        if (K - div)%2 == 0:
            answer = abs(X + div*D)
        else:
            answer = X + (div+1)*D X < 0 X 0 div, mod = divmod(-X, D) div divmod(-X, D) divmod -X X D mod if div >= K:
        answer = abs(X + K*D)
    else:
        if (K - div)%2 == 0:
            answer = abs(X + div*D)
        else:
            answer = X + (div+1)*D div >= K div K answer = abs(X + K*D) answer abs(X + K*D) abs X + K*D X K*D K D if (K - div)%2 == 0:
            answer = abs(X + div*D)
        else:
            answer = X + (div+1)*D (K - div)%2 == 0 (K - div)%2 K - div K div 2 0 answer = abs(X + div*D) answer abs(X + div*D) abs X + div*D X div*D div D answer = X + (div+1)*D answer X + (div+1)*D X (div+1)*D div+1 div 1 D if K%2 == 0:
        answer = 0
    else:
        answer = D K%2 == 0 K%2 K 2 0 answer = 0 answer 0 answer = D answer D print(answer) print answer mod = divmod(X, D) divmod(X, D) mod answer = 0 0 answer answer = X - K*D X - K*D answer answer = X + (div+1)*D X + (div+1)*D answer X, K, D = (int(x) for x in input().split()) (int(x) for x in input().split()) X answer = abs(X + K*D) abs(X + K*D) answer answer = X - div*D X - div*D answer D = (int(x) for x in input().split()) (int(x) for x in input().split()) D div, mod = divmod(-X, D) divmod(-X, D) div answer = abs(X + div*D) abs(X + div*D) answer answer = abs(X - (div+1)*D) abs(X - (div+1)*D) answer mod = divmod(-X, D) divmod(-X, D) mod div, mod = divmod(X, D) divmod(X, D) div answer = D D answer K, D = (int(x) for x in input().split()) (int(x) for x in input().split()) K
X, K, D = (int(x) for x in input().split())

if X > 0:
    div, mod = divmod(X, D)
    if div >= K:
        answer = X - K*D
    else:
        if (K - div)%2 == 0:
            answer = X - div*D
        else:
            answer = abs(X - (div+1)*D)
elif X < 0:
    div, mod = divmod(-X, D)
    if div >= K:
        answer = abs(X + K*D)
    else:
        if (K - div)%2 == 0:
            answer = abs(X + div*D)
        else:
            answer = X + (div+1)*D
else:
    if K%2 == 0:
        answer = 0
    else:
        answer = D

print(answer)
