How many enemies will challenge my party of four 1st-level characters, but not result in certain death?

I was asked to DM for a one-shot with people wanting to try and learn the game. I have created a not-too-complicated world in which they can run around and interact with its inhabitants.

The problem I face is the number and strength of foes that can be encountered. How do I prepare a challenge to the players while they learn the game? I want them to be a little afraid while still having chance of saving the town/rescuing the princess or prince/find the treasure.

  • These are completely new players, there will be 4 of them.
  • They will play level 1 characters: a paladin, barbarian, rogue and sorcerer.
  • I play a separate campaign with other people but have never been a DM before.
  • We expect to play for about 4 hours – unless everyone is having fun and wants to continue, of course.
  • Based on decisions, the enemies will be either goblins or pirates. I tend to keep these enemies around the same level.
  • I would like to introduce one “boss” in the shape of a goblin chief/pirate captain.

How many enemies, based on the information above, would make for a balanced and fun game? I don’t really want everyone to bite the dust on their first game ever, but also want to keep it interesting at the same time.