x,k,d = map(int,input().split(' '))
a = abs(x) % d 
b = -(a - d)
if abs(x) // d > k:
    ans = abs(x) - k * d
else:
    if a == b:
        ans = a
    else:
        if a < b:
            n1 = a
            n2 = b
        if b < a:
            n1 = b
            n2 = a
        if k % 2 == (abs(x) // d) % 2:
            ans = a
        else:
            ans = b
print(ans) x,k,d = map(int,input().split(' ')) x map(int,input().split(' ')) map int input().split(' ') ().split () input split ' ' k d a = abs(x) % d a abs(x) % d abs(x) abs x d b = -(a - d) b -(a - d) a - d a d if abs(x) // d > k:
    ans = abs(x) - k * d
else:
    if a == b:
        ans = a
    else:
        if a < b:
            n1 = a
            n2 = b
        if b < a:
            n1 = b
            n2 = a
        if k % 2 == (abs(x) // d) % 2:
            ans = a
        else:
            ans = b abs(x) // d > k abs(x) // d abs(x) abs x d k ans = abs(x) - k * d ans abs(x) - k * d abs(x) abs x k * d k d if a == b:
        ans = a
    else:
        if a < b:
            n1 = a
            n2 = b
        if b < a:
            n1 = b
            n2 = a
        if k % 2 == (abs(x) // d) % 2:
            ans = a
        else:
            ans = b a == b a b ans = a ans a if a < b:
            n1 = a
            n2 = b
         a < b a b n1 = a n1 a n2 = b n2 b if b < a:
            n1 = b
            n2 = a
         b < a b a n1 = b n1 b n2 = a n2 a if k % 2 == (abs(x) // d) % 2:
            ans = a
        else:
            ans = b k % 2 == (abs(x) // d) % 2 k % 2 k 2 (abs(x) // d) % 2 abs(x) // d abs(x) abs x d 2 ans = a ans a ans = b ans b print(ans) print ans ans = a a ans x,k,d = map(int,input().split(' ')) map(int,input().split(' ')) x ans = abs(x) - k * d abs(x) - k * d ans a = abs(x) % d abs(x) % d a b = -(a - d) -(a - d) b n1 = b b n1 d = map(int,input().split(' ')) map(int,input().split(' ')) d n2 = b b n2 ans = b b ans n2 = a a n2 k,d = map(int,input().split(' ')) map(int,input().split(' ')) k n1 = a a n1 ans = a a ans
x,k,d = map(int,input().split(' '))
a = abs(x) % d 
b = -(a - d)
if abs(x) // d > k:
    ans = abs(x) - k * d
else:
    if a == b:
        ans = a
    else:
        if a < b:
            n1 = a
            n2 = b
        if b < a:
            n1 = b
            n2 = a
        if k % 2 == (abs(x) // d) % 2:
            ans = a
        else:
            ans = b
print(ans)