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

if r - l >= mod
  puts 0
  exit 0
end

index = 0
min = Float::MAX
l.upto(r - 1) do |i|
  break if index >= mod
  min = [min, i * (i + 1) % mod].min
  index += 1
end

puts min