l,r = gets.chomp.split(" ").map{|i|i = i.to_i}
#ij_min = l * (l+1)
#ij_max = r * (r-1)

if(r-l >= 2018) then puts 0
else 
  now_min = 2018
  (r-l).times do|ii|
    i = l+ii
    (r-i).times do|jj|
      j = i+jj+1
      now_min = [now_min, ((i*j)%2019)].min
    end
  end
  puts now_min
end