You lose a life every time you fail to complete a level. It takes 30 minutes to refill one life, and you can have a maximum of five lives restored this way.
If you purchase more lives from the heart store, there is no limit on how many lives you can have.