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

l = 2019 if l > 2019
r = 2019 if r > 2019

minimum = 2018

(l...r).each do |i|
  ((i + 1)..r).each do |j|
    rem = (i % 2019) * (j % 2019) % 2019
    minimum = rem if rem < minimum
  end
end

print minimum
