      program WalkingTakahashi
!
      implicit none
      integer(16) :: X,K,D
      integer(16) :: ans1,ans2
      intrinsic abs,mod
!
      read(*,*) X,K,D
!
      ans1 = abs(X)/D
      ans2 = ans1 + 1
!
      if(K > ans1) then
        if(mod(K-ans1,2) == 0) write(*,*) abs(X)-ans1*D
        if(mod(K-ans1,2) == 1) write(*,*) ans2*D-abs(X)
      else
        write(*,*) abs(X)-K*D
      end if
!
      end program WalkingTakahashi