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

if r < 2019
  puts l * r % 2019
elsif r == 2019
  puts 0
elsif l < 2019 && r > 2019
  puts 0
elsif l == 2019
  puts 0
else
  ll = l % 2019
  rr = r % 2019
  mm = [ll, rr].min
  if ll * rr > 2019
    puts (2019 / mm  + 1) * mm % 2019
  else
    puts mm * (mm + 1) % 2019
  end
end