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

if abs(X) > K * D:
    print(abs(X) - K * D)
    exit()

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

if abs(X) > K * D:
    print(abs(X) - K * D)
    exit()

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

print(ans)