How many times has this happened: You’ve finally nailed your budget — from rent to groceries to “fun money” — but then that stubborn check-engine light comes on. Next thing you know, you’re out a thousand bucks over a repair you didn’t see coming.

Then it hits you. There really should be a special “Murphy’s Law” line item in your budget.

But that’s where an emergency fund comes in. It’s that cushion of savings you keep around just in case you get hit with an unexpected expense that can throw your budget out of whack. But how should you use it — and how much should you put away? Keep reading.

  1. WHAT SHOULD I USE MY EMERGENCY FUND TO PAY FOR?

    Here’s what an emergency is not: a vacation to the Bahamas, a flash sale on your favorite brands, a birthday gift for your college bestie. Those should either fit into your budget already or be goals that you’re saving for separately; don’t dip into an emergency savings account to pay for them.

    So, what warrants a withdrawal? Here are a few examples: Losing your job after signing a lease on that new apartment — when the rent is due. A seemingly harmless toothache that turns into an expensive root canal. A storm that sends a tree crashing through your roof. A last-minute plane ticket to attend a loved one’s funeral. In other words, out-of-the-blue expenses that are hard to avoid.

  2. HOW MUCH DO I NEED TO SAVE IN AN EMERGENCY FUND?

    How much you should keep in your emergency fund depends a lot on your situation, but it’s a good idea to save at least one month of take-home pay to start. In fact, we recommend prioritizing that one-month savings before you prioritize any other financial goals, like throwing extra money at your student loan or aggressively beefing up your retirement account. That’s because emergency situations tend to be big-ticket items, and without a fund to pay for them, you may have to ring up that credit card (and who needs more debt?).

    Then it hits you. There really should be a special “Murphy’s Law” line item in your budget.

    Once you’ve reached the one-month mark, you’re in a good place to start spreading the love to your other goals. But you’re not done: You should still keep putting money toward your emergency fund simultaneously, even if it’s just $50 or $100 a month, until you have about six months’ worth of take-home pay stashed away.

    If you have family or friends who you know would help you out in the event of an emergency, then you may need less in your emergency fund — perhaps closer to three months. If you have an unpredictable income, like if you’re a freelancer or are self-employed, you may want to sock away up to nine. For most people, though, six months is a comfortable benchmark.

  3. WHERE SHOULD I KEEP MY EMERGENCY FUND?

    If an emergency hits, you’d need fast access to your cash, so you don’t want these funds tied up in an investment account. But you don’t want them in your checking account either, because your emergency money should not be mixed in with your everyday money.

    Opt for a savings account instead — and one that’s separate from savings accounts you have going for other goals. (You wouldn’t want your vacation fund depleted because of every flat tire or emergency-room visit.)

    And for a little extra boost, consider keeping your emergency fund in a high-yield savings account, so that you’re making some interest off your money and it can grow a little faster.

Here’s another pro tip: Figure out how much you can comfortably funnel into your emergency fund each month, and then automate a recurring transfer from your checking account to your emergency savings account. Chances are you won’t even miss the extra cash — and your future self will thank you the next time a crisis strikes.

Recommended Reading