program ccc

implicit none
integer(8) :: l, r, i, one, two

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

one=mod(l*(l+1),2019)
two=mod(r*(r-1),2019)

write(*,'(i0)') min(one,two)

end program