program answer
  implicit none
  integer(16) :: i, x, k, d, count
  read(*,*) X, K, D

if(x==0) then
     if(mod(k,2)==0) then
        write(*,*) D
        stop
     else
        write(*,*) '0'
        stop
     end if
  end if

  if(x<0) then
     if(x+k*d>=0) then
        count=0
        do
           if(x>=0) then
              exit
           end if
           x=x+d
           count=count+1
        end do
        if(mod(count,2)==0) then
           if(mod(k,2)==0) then
              write(*,*) abs(x)
              stop
           else
              write(*,*) abs(x-d)
              stop
           end if
        else
           if(mod(k,2)==0) then
              write(*,*) abs(x-d)
              stop
           else
              write(*,*) abs(x))
              stop
           end if
        end if
      else
           write(*,*) abs(x+k*d)
           stop
     end if
  else
     if(x-k*d<=0) then
        count=0
        do
           if(x<=0) then
              exit
           end if
           x=x-d
           count=count+1
        end do
        if(mod(count,2)==0) then
           if(mod(k,2)==0) then
              write(*,*) abs(x)
              stop
           else
              write(*,*) abs(x+d)
              stop
           end if
        else
           if(mod(k,2)==0) then  
              write(*,*) abs(x+d)
              stop
           else
              write(*,*) abs(x)
              stop
           end if
        end if
     else
        write(*,*) abs(x-k*d)
        stop
     end if
  end if

  stop
 end program answer