def method_name(l, r)
  mod_l = l % 2019
  range = (mod_l..(mod_l + r - l)).to_a
  return 0 if mod_l == 0 || range.size >= 2019

  ans = 2019
  range.combination(2) do |p1, p2|
    q = p1 * p2 % 2019
    ans = q if q < ans
  end
  return ans
end

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