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

ans = 2019

if L % 2019 == 0 || R % 2019 == 0
  puts 0
  exit 0
end

if L / 2019 < R / 2019
  puts 0
  exit 0
end

(L..R).to_a.combination(2) do |r, l|
  ans = [ans, r * l % 2019].min
end

puts ans