program main
implicit none

integer*8 x,k,d,i,j,oldX
j=1
read(*,*) x,k,d
! write(*,*) min(x%d)
oldX = x
do i=1,k
  if(x.lt.0) then
    x = x+d
  else
    x = x-d
  endif
  if(sign(j,x).ne.sign(j,oldX)) then
    write(*,*) abs(x + modulo(k,2)*sign(j,oldX)*d)
    stop
  endif
enddo
write(*,*) abs(x)

end program
