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

ans_min = X % D

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

ans_min = X % D

if K <= X_div_D:
  print(X - K * D)
else:
  if (K % 2) ^ (X_div_D % 2) == 0:
    print(ans_min)
  else:
    print(abs(ans_min - D))