l,r = gets.split(" ").map{|e| e.to_i}
min = 2019
l.upto(r-1) do |i|
  tmp = i%2019
  if tmp == 0 || tmp == 2018
    min = 0
    break
  end
  j = tmp+1
  min = (tmp*j)%2019 if min > (tmp*j)%2019
end
puts min

