def method_name(l, r)
  mod_l = l % 2019
  size = r - l + 1
  range = (mod_l..(size-1)).to_a

  return 0 if mod_l == 0 || mod_l + size - 1 >= 2019
  return 0 if range.include?(3) && range.include?(673)

  qs = []
  range.combination(2) do |p1, p2|
    qs << p1 * p2 % 2019
  end
  return qs.min
end

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

puts method_name(l, r)