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