program test
integer,allocatable::x(:),y(:),z(:),w(:)
integer::r,l,ans,k,i
check=1
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 i=1,k
    	x(i)=l+i-1
    end do
   	do i=1,k
    	y(i)=mod(x(i),673)
        z(i)=mod(x(i),3)
    end do 
   		if(minval(y)==0 .and. minval(z)==0) then
        	ans=0
        else
        	do i=1,k
            	x(0)=x(k)
    		do i=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