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