R, L = gets.chomp.split(' ').map(&:to_i)
ans = 2_019
if R - L >= 2_019
  ans = 0
else
  RR = R
  count = 0
  while RR <= L
    if RR == R
      RR += 1
      count += 1
      next
    end
    count.times do |c|
      ans = [(R + c) * RR % 2_019, ans].min
      #   puts "ans:#{(R + c) * RR % 2_019}"
    end
    RR += 1
    count += 1
  end
end
puts ans
