l, r = gets.split.map(&:to_i)
r = [l + 2019, r].min

list = []
(l..r - 1).each do |i|
  (i + 1..r).each do |j|
    if list.include?(i * j % 2019)
      puts list.min
      return
    else
      list << i * j % 2019
    end
  end
end
puts list.min