program test
integer,allocatable::x(:),y(:),z(:),w(:)
integer::r,l,ans,k
integer::p,j,f
read(*,*)l,r
if(r-l+1>=673)then
	ans=0
else 
	k=r-l+1
    allocate(x(1:k))
    allocate(y(1:k))
    allocate(z(1:k))
    allocate(w(1:k))
    do j=1,k
    	x(j)=l+j-1
    end do
   	do f=1,k
    	y(f)=mod(x(f),673)
        z(f)=mod(x(f),3)
    end do 
   		if(minval(y)==0 .and. minval(z)==0) then
        	ans=0
        else
           	x(0)=x(k)
    		do p=1,k
    		w(i)=mod(x(i-1)*x(i),2019)
    		end do
  			ans=minval(w)
        end if
end if
print*,ans
end program test