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

n=math.ceil(X/D)
m=math.floor(X/D)

n_moveto0=0

if abs(X-n*D) <= abs(X-m*D):
  n_moveto0=abs(n)
  x_min=X-n*D
else: 
  n_moveto0=abs(m)
  x_min=X-m*D


if n_moveto0>=K:
  print(min([abs(X-D*K),abs(X+D*K)]))
else:
  if (K-n_moveto0)%2==0:
    print(abs(x_min))
  else:
    print(min([abs(x_min+D),abs(x_min-D)])) import math math X,K,D=map(int,input().split(' ')) X map(int,input().split(' ')) map int input().split(' ') ().split () input split ' ' K D n=math.ceil(X/D) n math.ceil(X/D) math.ceil math ceil X/D X D m=math.floor(X/D) m math.floor(X/D) math.floor math floor X/D X D n_moveto0=0 n_moveto0 0 if abs(X-n*D) <= abs(X-m*D):
  n_moveto0=abs(n)
  x_min=X-n*D
else: 
  n_moveto0=abs(m)
  x_min=X-m*D abs(X-n*D) <= abs(X-m*D) abs(X-n*D) abs X-n*D X n*D n D abs(X-m*D) abs X-m*D X m*D m D n_moveto0=abs(n) n_moveto0 abs(n) abs n x_min=X-n*D x_min X-n*D X n*D n D n_moveto0=abs(m) n_moveto0 abs(m) abs m x_min=X-m*D x_min X-m*D X m*D m D if n_moveto0>=K:
  print(min([abs(X-D*K),abs(X+D*K)]))
else:
  if (K-n_moveto0)%2==0:
    print(abs(x_min))
  else:
    print(min([abs(x_min+D),abs(x_min-D)])) n_moveto0>=K n_moveto0 K print(min([abs(X-D*K),abs(X+D*K)])) print min([abs(X-D*K),abs(X+D*K)]) min [abs(X-D*K),abs(X+D*K)] abs(X-D*K) abs X-D*K X D*K D K abs(X+D*K) abs X+D*K X D*K D K if (K-n_moveto0)%2==0:
    print(abs(x_min))
  else:
    print(min([abs(x_min+D),abs(x_min-D)])) (K-n_moveto0)%2==0 (K-n_moveto0)%2 K-n_moveto0 K n_moveto0 2 0 print(abs(x_min)) print abs(x_min) abs x_min print(min([abs(x_min+D),abs(x_min-D)])) print min([abs(x_min+D),abs(x_min-D)]) min [abs(x_min+D),abs(x_min-D)] abs(x_min+D) abs x_min+D x_min D abs(x_min-D) abs x_min-D x_min D x_min=X-m*D X-m*D x_min n_moveto0=0 0 n_moveto0 m=math.floor(X/D) math.floor(X/D) m K,D=map(int,input().split(' ')) map(int,input().split(' ')) K D=map(int,input().split(' ')) map(int,input().split(' ')) D x_min=X-n*D X-n*D x_min n_moveto0=abs(m) abs(m) n_moveto0 n=math.ceil(X/D) math.ceil(X/D) n n_moveto0=abs(n) abs(n) n_moveto0 X,K,D=map(int,input().split(' ')) map(int,input().split(' ')) X
import math
X,K,D=map(int,input().split(' '))

n=math.ceil(X/D)
m=math.floor(X/D)

n_moveto0=0

if abs(X-n*D) <= abs(X-m*D):
  n_moveto0=abs(n)
  x_min=X-n*D
else: 
  n_moveto0=abs(m)
  x_min=X-m*D


if n_moveto0>=K:
  print(min([abs(X-D*K),abs(X+D*K)]))
else:
  if (K-n_moveto0)%2==0:
    print(abs(x_min))
  else:
    print(min([abs(x_min+D),abs(x_min-D)]))
