program main
implicit none
integer(8) :: l, r, i, j

read(*,*) l, r
if( r - l .ge. 2019 ) then 
   write(*,'(i0)') 0
   stop
else
   if( r/2019 /= l/2019 ) then
      write(*,'(i0)') 0
      stop
   else
      i = mod(l,2019)*mod(l+1,2019)
      j = mod(r,2019)*mod(r-1,2019)
      write(*,'(i0)') min( mod(i,2019), mod(j,2019) )
      stop
   end if
end if
end program main
