l, r = gets.chomp.split.map(&:to_i)

res = 2019
vars = [2019, r-l+1].min

(0...vars).each do |li|
    (li+1...vars).each do |ri|
        lv = l + li
        rv = l + ri
        var = (lv * rv) % 2019
        res = var if var < res
    end
end

puts res
