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

lrange = l % 2019
rrange = r % 2019

minrange = [lrange, rrange].min
maxrange = [lrange, rrange].max

if minrange == maxrange
  puts 0
else
  ans = 2100
  (minrange..maxrange-1).each do |i|
    ((minrange+1)..maxrange).each do |j|
      ans = [ans, i * j % 2019].min
    end
  end
  puts ans
end
