x, k,d = map(int, input().split())
x = abs(x)
ans = 0
if x//d>k:
    ans = abs(x-d*k)
else:
    tmp = x//d
    k -= tmp
    x -= tmp*d
    if k%2 == 1:
        ans = abs(x-d)
    else:
        ans = abs(x)
print(ans) x, k,d = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split k d x = abs(x) x abs(x) abs x ans = 0 ans 0 if x//d>k:
    ans = abs(x-d*k)
else:
    tmp = x//d
    k -= tmp
    x -= tmp*d
    if k%2 == 1:
        ans = abs(x-d)
    else:
        ans = abs(x) x//d>k x//d x d k ans = abs(x-d*k) ans abs(x-d*k) abs x-d*k x d*k d k tmp = x//d tmp x//d x d k -= tmp k tmp x -= tmp*d x tmp*d tmp d if k%2 == 1:
        ans = abs(x-d)
    else:
        ans = abs(x) k%2 == 1 k%2 k 2 1 ans = abs(x-d) ans abs(x-d) abs x-d x d ans = abs(x) ans abs(x) abs x print(ans) print ans x = abs(x) abs(x) x k -= tmp tmp k tmp = x//d x//d tmp ans = abs(x-d) abs(x-d) ans x -= tmp*d tmp*d x d = map(int, input().split()) map(int, input().split()) d ans = 0 0 ans ans = abs(x-d*k) abs(x-d*k) ans k,d = map(int, input().split()) map(int, input().split()) k ans = abs(x) abs(x) ans x, k,d = map(int, input().split()) map(int, input().split()) x
x, k,d = map(int, input().split())
x = abs(x)
ans = 0
if x//d>k:
    ans = abs(x-d*k)
else:
    tmp = x//d
    k -= tmp
    x -= tmp*d
    if k%2 == 1:
        ans = abs(x-d)
    else:
        ans = abs(x)
print(ans)