program abc133c
   implicit none

   integer(8) :: L, R, i, j , skip
   integer :: ans, calc_mod

   read(*,*) L, R

   ans = 2018

   do i = L, R-1
      do j =i+1, R

         calc_mod = mod(i*j,2019)
         if (ans > calc_mod ) then
            ans = calc_mod
            if (ans == 0) goto 999
         else
            cycle
         end if
      enddo
   enddo
999 continue

   print *, ans


end program abc133c
