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

lrange = l % 2019
rrange = r % 2019

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

ans = 2100

(minrange..maxrange).each do |i|
  (minrange..maxrange).each do |j|
    ans = [ans, i * j % 2019].min
  end
end
puts ans
