      PROGRAM walkingTakahashi
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 16
      integer(p) :: x,k,d, right,left
      
      read*,x,k,d
      
      x = abs(x)
      
      !rightまでたどり着かないorギリ
      if( k<=x/d )then
        print*,x-k*d
        stop
      end if
      
      right = x - x/d*d
      k = k - x/d
      
      left = right - d
      
      if( mod(k,2)==0 )then
        print*,right
      else
        print*,abs(left)
      end if
      
      
      
      
      
      stop
      !debugg
      
      
      
      END PROGRAM