X, K, D = list(map(int, input().rstrip().split()))

before = X



if abs(X)//D>=K:

  print((abs(X)-D*K))

else:

  for i in range(K):

    buf = X

    if X<0:

      X += D

    else:

      X -= D

    if X == before:

      if (K-i)%2 == 0:

        if X<0:

          X += D

        else:

          X -= D

      else:

        X = before

      break

    before=buf

  print((abs(X)))
x,k,d = list(map(int,input().split()))

x = abs(x)

if x//d > k:

  print((x-k*d))

elif (k-x//d)%2 == 0:

  print((x%d))

else:

  print((d-x%d))
X, K, D = list(map(int, input().rstrip().split()))
before = X
if abs(X) // D >= K:
    print((abs(X) - D * K))
else:
    for i in range(K):
        buf = X
        if X < 0:
            X += D
        else:
            X -= D
        if X == before:
            if (K - i) % 2 == 0:
                if X < 0:
                    X += D
                else:
                    X -= D
            else:
                X = before
            break
        before = buf
    print((abs(X)))

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

-X, K, D = list(map(int, input().rstrip().split())) -before = X -if abs(X) // D >= K: -    print((abs(X) - D * K)) +x, k, d = list(map(int, input().split())) +x = abs(x) +if x // d > k: +    print((x - k * d)) +elif (k - x // d) % 2 == 0: +    print((x % d)) -    for i in range(K): -        buf = X -        if X < 0: -            X += D -        else: -            X -= D -        if X == before: -            if (K - i) % 2 == 0: -                if X < 0: -                    X += D -                else: -                    X -= D -            else: -                X = before -            break -        before = buf -    print((abs(X))) +    print((d - x % d))