program main
integer(16) :: l,r,i,j,m,mo,tmp,a
m=2019
read(*,*)l,r

do i = l,r
if (mod(i,2019)==0) then
m = 0
endif
end do

l = mod(l,2019)
r = mod(r,2019)
!if (r < l) then
!tmp = r
!r = l
!l = tmp
!end if

if (l /= r) then
do i = l,r-1
do j = i+1,r
mo = mod(i*j,2019)
if (m > mo) m = mo
end do
end do
write(*,*)m

else
write(*,*)l
end if

end program main