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

if 0<abs(X)<K*D:
  a=X//D
  K-=a
  if K%2==0:
    ans=X-D*a
  else:
    ans=X-D*(a+1)

else:
  ans=abs(X)-K*D
    
print(abs(ans)) X,K,D=map(int, input().split()) X map(int, input().split()) map int input().split() ().split () input split K D if 0<abs(X)<K*D:
  a=X//D
  K-=a
  if K%2==0:
    ans=X-D*a
  else:
    ans=X-D*(a+1)

else:
  ans=abs(X)-K*D
     0<abs(X)<K*D 0<abs(X) 0 abs(X) abs X K*D K D a=X//D a X//D X D K-=a K a if K%2==0:
    ans=X-D*a
  else:
    ans=X-D*(a+1) K%2==0 K%2 K 2 0 ans=X-D*a ans X-D*a X D*a D a ans=X-D*(a+1) ans X-D*(a+1) X D*(a+1) D a+1 a 1 ans=abs(X)-K*D ans abs(X)-K*D abs(X) abs X K*D K D print(abs(ans)) print abs(ans) abs ans K,D=map(int, input().split()) map(int, input().split()) K X,K,D=map(int, input().split()) map(int, input().split()) X ans=X-D*(a+1) X-D*(a+1) ans ans=abs(X)-K*D abs(X)-K*D ans D=map(int, input().split()) map(int, input().split()) D K-=a a K a=X//D X//D a ans=X-D*a X-D*a ans
X,K,D=map(int, input().split())

if 0<abs(X)<K*D:
  a=X//D
  K-=a
  if K%2==0:
    ans=X-D*a
  else:
    ans=X-D*(a+1)

else:
  ans=abs(X)-K*D
    
print(abs(ans))