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

array = Array.new(r - l + 1) { |n| l + n }
mods = []
array_2019 = Array.new(r / 2019) { |n| 2019 * n }

min = 0
unless (array - array_2019).size < array.size
  array.combination(2) do |i, j|
    mods.push(i * j % 2019)
  end
  min = mods.min
end

puts min
