local l,r=io.read("*n","*n")

if l%2019+r-l>=2019 then
    print(0)
else
    local minmod=2019
    for i=l,r-1 do
        for j=i+1,r do
            minmod=math.min(minmod,(i%2019)*(j%2019)%2019)
        end
    end
    print(minmod)
end