implicit none
integer :: l,r
integer,allocatable :: m(:)
integer :: i,s

read *,l,r
allocate(m(l:r))
do i = l,r
   m(i) = mod(i,2019)
enddo

i = minloc(m,DIM=1) + l - 1
s = m(i)
m(i) = 2019

write(*,'(i0)') mod(s * minval(m),2019)
end