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

num_loop = R - L
if num_loop >= 2019
  puts 0
  exit
end

min_m = 2019
0.upto(num_loop) do |i|
  (i + 1).upto(num_loop) do |j|
    m = ((L + i) * (L + j)) % 2019
    min_m = m if m < min_m
  end
end
puts min_m
