def search(p, l, r)
  if l % p == 0
    return true
  else
    x = (l / p) * p + p
    return (x <= r) ? true : false
  end
end

l, r = gets.split.map(&:to_i)
if search(2019, l, r)
  puts 0
elsif search(3, l, r) && search(673, l, r)
  puts 0
else
  puts l * (l + 1) % 2019
end
