The formula for the margin of error of a given sample size is e = (zσ)/√n, where n is the sample size and σ is the standard deviation. If you solve this for an unknown n, the formula is [(zσ)/e]2.
Since this margin of error is given as a percentage, this is a standard normal distribution with a mean of 0 and a standard deviation of 1. The only other thing we need to know. We may be given this, or we may have a normal distribution calculator or table that tells us that a confidence level of 90% has a z value of 1.28. Now we have everything we need to put into our formula.
n = [(1.28*1)/0.02]2 = 642 = 4096.