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

# p L.upto(R).to_a
# p L.upto(R).map { |i| i % 2019 }

def solve
  if (R - L) > 2019
    p 0
    return
  end

  mods = []
  L.upto(R).each do |i|
    mod = i % 2019
    mods << mod
  end

  # p [L, R]
  # p mods

  min = 2019 * 2019 + 1
  0.upto(mods.size - 1).each do |i|
    (i + 1).upto(mods.size - 1).each do |j|
      k = (mods[i] * mods[j]) % 2019
      if (k < min)
        min = k
      end
    end
  end
  
  p min
end

solve