program abc41
 implicit none
 integer(8)::X,K,D,Z,Y,ans,L
 read(*,*)X,K,D
 Y=abs(X)
 if(Y>K*D)then
  print'(i0)',Y-K*D
  stop
 end if
 L=K-nint(real((Y-mod(Y,D))/D))
 Z=mod(Y,D)
 if(mod(L,2)==0)then
  print'(i0)',Z
 else
  print'(i0)',D-Z
 end if
end program abc41