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

c = abs(X) // D
k = min(c, K)
K -= k
if K == 0:
    if X > 0:
        print(abs(X-D*k))
        exit()
    elif X < 0:
        print(abs(X+D*k))
        exit()

if X > 0:
    X -= D*k
    if abs(X-D) < abs(X):
        X -= D
        K -= 1
elif X < 0:
    X += D*k
    if abs(X+D) < abs(X):
        X += D
        K -= 1

if K % 2 == 0:
    print(abs(X))
else:
    print(min(abs(X-D), abs(X+D))) X, K, D = map(int, input().split()) X map(int, input().split()) map int input().split() ().split () input split K D c = abs(X) // D c abs(X) // D abs(X) abs X D k = min(c, K) k min(c, K) min c K K -= k K k if K == 0:
    if X > 0:
        print(abs(X-D*k))
        exit()
    elif X < 0:
        print(abs(X+D*k))
        exit() K == 0 K 0 if X > 0:
        print(abs(X-D*k))
        exit()
    elif X < 0:
        print(abs(X+D*k))
        exit() X > 0 X 0 print(abs(X-D*k)) print abs(X-D*k) abs X-D*k X D*k D k exit() exit elif X < 0:
        print(abs(X+D*k))
        exit() X < 0 X 0 print(abs(X+D*k)) print abs(X+D*k) abs X+D*k X D*k D k exit() exit if X > 0:
    X -= D*k
    if abs(X-D) < abs(X):
        X -= D
        K -= 1
elif X < 0:
    X += D*k
    if abs(X+D) < abs(X):
        X += D
        K -= 1 X > 0 X 0 X -= D*k X D*k D k if abs(X-D) < abs(X):
        X -= D
        K -= 1 abs(X-D) < abs(X) abs(X-D) abs X-D X D abs(X) abs X X -= D X D K -= 1 K 1 elif X < 0:
    X += D*k
    if abs(X+D) < abs(X):
        X += D
        K -= 1 X < 0 X 0 X += D*k X D*k D k if abs(X+D) < abs(X):
        X += D
        K -= 1 abs(X+D) < abs(X) abs(X+D) abs X+D X D abs(X) abs X X += D X D K -= 1 K 1 if K % 2 == 0:
    print(abs(X))
else:
    print(min(abs(X-D), abs(X+D))) K % 2 == 0 K % 2 K 2 0 print(abs(X)) print abs(X) abs X print(min(abs(X-D), abs(X+D))) print min(abs(X-D), abs(X+D)) min abs(X-D) abs X-D X D abs(X+D) abs X+D X D k = min(c, K) min(c, K) k X += D D X X += D*k D*k X D = map(int, input().split()) map(int, input().split()) D X -= D D X K -= k k K X -= D*k D*k X X, K, D = map(int, input().split()) map(int, input().split()) X K -= 1 1 K K -= 1 1 K c = abs(X) // D abs(X) // D c K, D = map(int, input().split()) map(int, input().split()) K
X, K, D = map(int, input().split())

c = abs(X) // D
k = min(c, K)
K -= k
if K == 0:
    if X > 0:
        print(abs(X-D*k))
        exit()
    elif X < 0:
        print(abs(X+D*k))
        exit()

if X > 0:
    X -= D*k
    if abs(X-D) < abs(X):
        X -= D
        K -= 1
elif X < 0:
    X += D*k
    if abs(X+D) < abs(X):
        X += D
        K -= 1

if K % 2 == 0:
    print(abs(X))
else:
    print(min(abs(X-D), abs(X+D)))
