(Z-score)2 x SD x (1-SD)/ME2 = Sample Size

I know there are some thumb rules to get the sample size but I am wandering whether there is a more mathematical way to get it. I would be grateful if anyone can suggest me a method. I checked FAQs , a text book, other threads, and googled it but could not find a proper answer.

Thank you for your attention.