X, K, D = map(int, input().split())
if X < 0:
    X = -X
step = X//D
X -= D*step
K -= step

if K <= 0:
    print(X-K*D)
    exit()
if K % 2 == 0:
    print(X)
else:
    print(abs(X-D)) X, K, D = map(int, input().split()) X map(int, input().split()) map int input().split() ().split () input split K D if X < 0:
    X = -X X < 0 X 0 X = -X X -X X step = X//D step X//D X D X -= D*step X D*step D step K -= step K step if K <= 0:
    print(X-K*D)
    exit() K <= 0 K 0 print(X-K*D) print X-K*D X K*D K D exit() exit if K % 2 == 0:
    print(X)
else:
    print(abs(X-D)) K % 2 == 0 K % 2 K 2 0 print(X) print X print(abs(X-D)) print abs(X-D) abs X-D X D X, K, D = map(int, input().split()) map(int, input().split()) X step = X//D X//D step X = -X -X X X -= D*step D*step X D = map(int, input().split()) map(int, input().split()) D K, D = map(int, input().split()) map(int, input().split()) K K -= step step K
X, K, D = map(int, input().split())
if X < 0:
    X = -X
step = X//D
X -= D*step
K -= step

if K <= 0:
    print(X-K*D)
    exit()
if K % 2 == 0:
    print(X)
else:
    print(abs(X-D))
