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



if abs(X) > K*D:

    print((abs(X) - K*D))

else:

    X = abs(X)

    K -= X//D

    X = X%D

    if K%2 == 0:

        print(X)

    else:

        print((abs(X-D)))
X, K, D = list(map(int, input().split()))

X = abs(X)

if X > K*D:

    print((X-K*D))

else:

    K -= X//D

    X %= D

    if K%2 == 0:

        print(X)

    else:

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

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

-if abs(X) > K * D: -    print((abs(X) - K * D)) +X = abs(X) +if X > K * D: +    print((X - K * D)) -    X = abs(X) -    X = X % D +    X %= D -        print((abs(X - D))) +        print((D - X))