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