Suppose I want to use Monte Carlo to compute some probability $p$. A single MC simulation will run for $R$ iterations and calculate $p$ as the fraction of 'successes'.
Say I want to compute $p$ within an error of $E$ with a 95% confidence interval. That is, I want to find $R_0$ such that if I run the MC simulation for $R_0$ many times and obtain $p_0$, then I am $95\%$ confident that the true $p$ lies in $[p_0 - E, p_0 + E]$.
I found two possible formulas for this: one and two but they are different (albeit similar), and they also don't really seem to take $R$ into account, which doesn't make intuitive sense to me.
For instance, the second link has the formula:
$$\bigg(\frac{z_{\alpha/2} \cdot \text{std}(p)}{E}\bigg)^2$$
$\text{std}(p)$, I assume will be computed by Monte Carlo sampling $p_1, \dots, p_n$ (with some fixed $R$ iterations for each $p_i$), and the finding the standard deviation of the $p_i$. But naturally this standard deviation would decrease as $R$ increases. So it seems to me that the formula should factor in $R$ somehow, which it isn't.
Is my interpretation incorrect?
Is there a simple formula to determine number of simulations required?