program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,k,m,n,ans
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) a,b
    if(mod(a,2019)==0 .or. mod(b,2019)==0)then

        write(*,*)0
        stop
    elseif(b/2019-a/2019/=0)then
        write(*,*)0
        stop
    else
        a=mod(a,2019)
        b=mod(b,2019)
    end if
    ans=10000
    do i=a,b-1
        do j=i+1,b
            c=mod(i*j,2019)
            if(c==0)then
                write(*,*)0
                stop
            elseif(c<ans)then
                ans=c
            end if
        end do
    end do
    write(*,*)ans

    stop
end program sample
  

