program ccc

implicit none
integer(8) :: l, r, i, ans

read*, l, r

do i=1,10000
if(l>=2019) then
l=l-2019
r=r-2019
else
exit
end if
end do

if(r>=2019) then
write(*,'(i0)') 0
return
end if

ans=1000000

do i=l, r-1
ans=min(ans,mod(i*(i+1),2019))
end do

write(*,'(i0)') ans

end program