When to Save and When to Invest