How many simulations do we need for simulation-based inference in cosmology?