You can set up the interval of a 95% confidence interval for any sample size, the question is how wide it is. So assuming the confidence interval so be smaller than L what should the sample size be? Well given that you are using the simple sample average as estimator andSo for example, to calcuate how many times would I need to toss a coin to observe that p(heads)=0.5, within 95%CI?

you assume it is approximately standard normal the 95% confidence interval +/- 1.96 standard errors. So the total length is about 4 standard errors and the standard error is sqrt(p(1-p)/n).... p(1-p) is maximized for p=0.5 ... so if n is chosen large enough to ensure an interval shorter than L for p=0.5 it will also hold when p is not 0.5.

you can read more http://en.wikipedia.org/wiki/Sample_size_determination