X, K, D = map(int, input().split())
x = abs(X)


if x//D <= K:
  if (K-x//D)%2 == 0:
    print(min(x, x%D))
  else:
    print(abs(D-x%D))
else:
  print(x-K*D) 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 if x//D <= K:
  if (K-x//D)%2 == 0:
    print(min(x, x%D))
  else:
    print(abs(D-x%D))
else:
  print(x-K*D) x//D <= K x//D x D K if (K-x//D)%2 == 0:
    print(min(x, x%D))
  else:
    print(abs(D-x%D)) (K-x//D)%2 == 0 (K-x//D)%2 K-x//D K x//D x D 2 0 print(min(x, x%D)) print min(x, x%D) min x x%D x D print(abs(D-x%D)) print abs(D-x%D) abs D-x%D D x%D x D print(x-K*D) print x-K*D x K*D K D X, K, D = map(int, input().split()) map(int, input().split()) X K, D = map(int, input().split()) map(int, input().split()) K D = map(int, input().split()) map(int, input().split()) D x = abs(X) abs(X) x
X, K, D = map(int, input().split())
x = abs(X)


if x//D <= K:
  if (K-x//D)%2 == 0:
    print(min(x, x%D))
  else:
    print(abs(D-x%D))
else:
  print(x-K*D)