# AtCoder Beginner Contest 175

# C - Walking Takahashi



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



KOE=K%2



A=abs(X)//D

M=abs(X)%D



# print(A)



if K<=A:

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

    exit()



else :

    if A%2==KOE:

        print(M)

    else :

        print((min(abs(M+D),abs(M-D))))
# AtCoder Beginner Contest 175

# C - Walking Takahashi



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



X=abs(X)



A=X//D

M=X%D



if K<=A:

    print((X-K*D))

    exit()



else :

    if A%2==K%2:

        print(M)

    else :

        print((min(abs(M+D),abs(M-D))))
# AtCoder Beginner Contest 175
# C - Walking Takahashi
X, K, D = list(map(int, input().split()))
KOE = K % 2
A = abs(X) // D
M = abs(X) % D
# print(A)
if K <= A:
    print((abs(X) - K * D))
    exit()
else:
    if A % 2 == KOE:
        print(M)
    else:
        print((min(abs(M + D), abs(M - D))))

# AtCoder Beginner Contest 175
# C - Walking Takahashi
X, K, D = list(map(int, input().split()))
X = abs(X)
A = X // D
M = X % D
if K <= A:
    print((X - K * D))
    exit()
else:
    if A % 2 == K % 2:
        print(M)
    else:
        print((min(abs(M + D), abs(M - D))))

-KOE = K % 2 -A = abs(X) // D -M = abs(X) % D -# print(A) +X = abs(X) +A = X // D +M = X % D -    print((abs(X) - K * D)) +    print((X - K * D)) -    if A % 2 == KOE: +    if A % 2 == K % 2: