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

mn = 2019
1.upto(5000) do |k|
  i = l + k
  break if i > r
  k.times do |b|
    j = l + b
    mn = [(i*j) % 2019, mn].min
    #p [i, j, (i*j)%2019]
    if mn == 0
      puts 0
      exit 0
    end
  end
end

puts mn
