X,K,D=(int(x) for x in input().split())
x=abs(X)
a=x//D
 
b=x-a*D
B=abs(x-(a+1)*D)
 
if b>B:
  a=a+1
 
if a>=K:
  print(abs(x-K*D))
 
else:
  c=K-a
  if c%2 == 0:
    print(abs(x-a*D))
  else:
    d=abs(x-(a-1)*D)
    e=abs(x-(a+1)*D)
    print(min(d,e)) int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x X,K,D=(int(x) for x in input().split()) X (int(x) for x in input().split()) K D x=abs(X) x abs(X) abs X a=x//D a x//D x D b=x-a*D b x-a*D x a*D a D B=abs(x-(a+1)*D) B abs(x-(a+1)*D) abs x-(a+1)*D x (a+1)*D a+1 a 1 D if b>B:
  a=a+1
  b>B b B a=a+1 a a+1 a 1 if a>=K:
  print(abs(x-K*D))
 
else:
  c=K-a
  if c%2 == 0:
    print(abs(x-a*D))
  else:
    d=abs(x-(a-1)*D)
    e=abs(x-(a+1)*D)
    print(min(d,e)) a>=K a K print(abs(x-K*D)) print abs(x-K*D) abs x-K*D x K*D K D c=K-a c K-a K a if c%2 == 0:
    print(abs(x-a*D))
  else:
    d=abs(x-(a-1)*D)
    e=abs(x-(a+1)*D)
    print(min(d,e)) c%2 == 0 c%2 c 2 0 print(abs(x-a*D)) print abs(x-a*D) abs x-a*D x a*D a D d=abs(x-(a-1)*D) d abs(x-(a-1)*D) abs x-(a-1)*D x (a-1)*D a-1 a 1 D e=abs(x-(a+1)*D) e abs(x-(a+1)*D) abs x-(a+1)*D x (a+1)*D a+1 a 1 D print(min(d,e)) print min(d,e) min d e D=(int(x) for x in input().split()) (int(x) for x in input().split()) D b=x-a*D x-a*D b B=abs(x-(a+1)*D) abs(x-(a+1)*D) B d=abs(x-(a-1)*D) abs(x-(a-1)*D) d a=x//D x//D a e=abs(x-(a+1)*D) abs(x-(a+1)*D) e x=abs(X) abs(X) x a=a+1 a+1 a c=K-a K-a c X,K,D=(int(x) for x in input().split()) (int(x) for x in input().split()) X K,D=(int(x) for x in input().split()) (int(x) for x in input().split()) K
X,K,D=(int(x) for x in input().split())
x=abs(X)
a=x//D
 
b=x-a*D
B=abs(x-(a+1)*D)
 
if b>B:
  a=a+1
 
if a>=K:
  print(abs(x-K*D))
 
else:
  c=K-a
  if c%2 == 0:
    print(abs(x-a*D))
  else:
    d=abs(x-(a-1)*D)
    e=abs(x-(a+1)*D)
    print(min(d,e))