L, R = gets.split(' ').map(&:to_i)

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
