program test
integer,allocatable::x(:),y(:)
integer::r,l,ans,k,i
read(*,*)l,r
if(r-l+1>=2019)then
	ans=0
else 
	k=r-l+1
    allocate(x(0:k))
    allocate(y(1:k))
    do i=1,k
    	x(i)=l+i-1
    end do
    	x(0)=x(k)
    do i=1,k
    	y(i)=mod(x(i-1)*x(i),2019)
    end do
  	ans=minval(y)
end if
	print*,ans
end program test