L,R = gets.split.map &:to_i
r = [R, L + 2019].min

min = 2019
L.upto(r-1) do |i|
  (i+1).upto(r) do |j|
    a = (i*j)%2019
    if a == 0
      puts 0
      exit
    end
    if a < min
      min = a 
    end
  end
end

puts min