OS X app store upgrade

I have a question about upgrading from snow leopard to mountain lion using the app store. If I were to later decide to reformat my computer for whatever reason, would I first need to reinstall snow leopard and then upgrade again using the app store? And if that is the case how many times am I aloud to use the upgrade?