L, R = gets.chomp.split(' ').map(&:to_i)
min = -1
(L..R).each do |n|
  if R >= 2019 && n + 1 >= 2019
    min = (n * (n + 1)) % 2019
    break
  end
  min = n * (n + 1) if min == -1 || min > (n * (n + 1))
end
print min
