l,r = gets.chomp.split(" ").map(&:to_i)
lmod = l%2019
rmod = r%2019

if r-l >= 2019 || lmod >= rmod
    puts 0
else
    min = lmod*(lmod+1) % 2019
    for i in lmod..rmod-1 do
        pro = i*(i+1) % 2019
        if pro < min 
            min = pro
        end
    end
    puts min
end