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

if L / 2019 != R / 2019 || l == 0
    puts 0
elsif l < 4 && r > 672
    puts 0
else
    ary = (l..r).to_a.map{|a| a %= 2019}.sort
    min = 2019
    (ary.size - 1).times do |i|
        j = i + 1
        while j < ary.size do
            tmp = (ary[i] * ary[j]) % 2019
            min = tmp if tmp < min
            j += 1
        end
    end
    puts min
end
