program main

  implicit none

  integer :: L, R, i, j, ans, ans_tmp
  integer, allocatable, dimension ( : ) :: a

  read ( unit = *, fmt = * ) L, R

  if ( R-L+1 >= 2019 ) then

     print '(i0)', 0

     stop

  end if
  
  allocate ( a ( 1:R-L+1 ) )

  do i = 1, R-L+1
     
     a ( i ) = mod ( L + i - 1, 2019 )

  end do

  ans = 2019
  
  do i = 1, R-L+1

     do j = 1, R-L+1

        if ( i == j ) then

           cycle

        end if

        ans_tmp = mod ( a ( i ) *  a ( j ), 2019 )

        if ( ans_tmp < ans ) ans = ans_tmp

        if ( ans == 0 ) then
           
           print '(i0)', 0

           stop

        end if
        

     end do

  end do

  print '(i0)', ans
  
  
end program main
