import math
X, K, D = map(int,input().split())
X = math.fabs(X)
ans = 0
E = X//D
if E > K:
    ans = X - K * D
elif K%2 == E%2:
    ans = X-E*D
else:
    ans = -X+(E+1)*D
print(int(ans)) import math math X, K, D = map(int,input().split()) X map(int,input().split()) map int input().split() ().split () input split K D X = math.fabs(X) X math.fabs(X) math.fabs math fabs X ans = 0 ans 0 E = X//D E X//D X D if E > K:
    ans = X - K * D
elif K%2 == E%2:
    ans = X-E*D
else:
    ans = -X+(E+1)*D E > K E K ans = X - K * D ans X - K * D X K * D K D elif K%2 == E%2:
    ans = X-E*D K%2 == E%2 K%2 K 2 E%2 E 2 ans = X-E*D ans X-E*D X E*D E D ans = -X+(E+1)*D ans -X+(E+1)*D -X X (E+1)*D E+1 E 1 D print(int(ans)) print int(ans) int ans E = X//D X//D E K, D = map(int,input().split()) map(int,input().split()) K ans = X - K * D X - K * D ans ans = -X+(E+1)*D -X+(E+1)*D ans ans = 0 0 ans D = map(int,input().split()) map(int,input().split()) D ans = X-E*D X-E*D ans X, K, D = map(int,input().split()) map(int,input().split()) X X = math.fabs(X) math.fabs(X) X
import math
X, K, D = map(int,input().split())
X = math.fabs(X)
ans = 0
E = X//D
if E > K:
    ans = X - K * D
elif K%2 == E%2:
    ans = X-E*D
else:
    ans = -X+(E+1)*D
print(int(ans))