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

min = 2019
(l..r - 1).each do |i|
  (i + 1..r).each do |j|
    m = (i * j) % 2019
    min = m if m < min
    if min == 0
      puts 0
      exit
    end
  end
end

puts min
