L, R = gets.split(' ').map{|n| n.to_i}
if R - L >= 2018
  puts 0
  exit
end
min, min_2 = 2019, 2019
(L..R).each do |v|
  if v % 2019 < min
    min, min_2 = v, min
  elsif v % 2019 < min_2
    min_2 = v
  end
end
puts (min * min_2) % 2019