x, k, d = map(int, input().split())

if x > 0:
    if x < k * d:
        if x // d % 2 == k % 2:
            g = x % d
        else:
            g = abs(d - (x % d))
    else:
        g = x - k * d
elif x == 0:
    if k % 2:
        g = d
    else:
        g = 0
else:
    if abs(x) < k * d:
        if abs(x) // d % 2 == k % 2:
            g = abs(x) % d
        else:
            g = abs(d - (abs(x) % d))
    else:
        g = abs(x) - k * d

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

if x > 0:
    if x < k * d:
        if x // d % 2 == k % 2:
            g = x % d
        else:
            g = abs(d - (x % d))
    else:
        g = x - k * d
elif x == 0:
    if k % 2:
        g = d
    else:
        g = 0
else:
    if abs(x) < k * d:
        if abs(x) // d % 2 == k % 2:
            g = abs(x) % d
        else:
            g = abs(d - (abs(x) % d))
    else:
        g = abs(x) - k * d

print(g)
