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

min = 2018
l.upto(r) do |i|
  if i % 2019 == 0
    puts 0
    exit
  end
  (i + 1).upto(r) do |j|
    if j % 2019 == 0
      puts 0
      exit
    end
    min = (i * j) % 2019 < min ? (i * j) % 2019 : min
  end
end

puts min
