This is highly dependent on how the ship operates. I'll try to offer guidelines best I can.
First let's talk shifts. There is no day/night in space, so you'll need to consider cycles/rotations, to ensure everyone is well rested. Humans tend to work best on a 22-26 hour cycle, depending on which study you read. For convenience sake, let's assume a 24 hour cycle.
How are you breaking this down into shifts? 8 hour shifts make the most sense, because it's hard to stay focused longer than that, and having some semblance of a life is important as well. But that means 16 hours of downtime per cycle, and that means they need more entertainment, and more crew to man each shift--not advisable.
Most commonly, there are 12 hour shifts. That means 12 hours of downtime, and roughly four that isn't assumed to be for sleeping. It's easier to 'hot bed', or to share the same bedding with the one working the opposite shift, reducing space required for this. This also means you need less crew in total to get the same work done.
So let's look at what you're looking at in terms of roles.
Captain: head of the ship, captain so to speak. Someone has to have the final say in all things, to ensure both a proper hierarchy and chain of command.
Lieutenants: Assuming 12-hour shifts, that means two direct subordinates to the captain. One would be the 'superior' of the two, given the captain cannot be awake 24 hours a cycle, and this 'higher ranked lieutenant' would need to work opposite shifts to the captain, to ensure things run smoothly in their absence.
How is the ship actually flown? Is there a pilot/co-pilot like an aircraft? Are the motions so complex you need 3-4 to actually control the spacecraft? Is this mostly handled with 'autopilot', and only done manually during specific instances (combat, take-off and landing, etc)?
Let's assume there is an autopilot function, but as a matter of course you opt to have a team ready to take over at all times. Redundancies in space are important, because one screw-up at the wrong moment means death for all.
So. Assuming you need 4 to fly it (manually work controls to ensure continued flight). That's 8 for the two shifts.
Navigator. Is this task given to the captain? Is this given to the lieutenants? Is there a separate roll that must be filled? Is this for one person? A team? Plotting a course could easily be left to some sort of Navicomputer, or astrodroid (to use Star Wars terminology). Or this could be a dedicated position one has to train for years to become proficient at, for a host of reasons. It could be the captain and lieutenants have to discuss this as a team. Or it could be that you need one per shift.
Turrets. Assuming there are defenses on your space craft. Some sort of turrets. Are these manned or unmanned? You'll need to plan this eventuality. Do you want dedicated gunners for them? How many turrets? Take shifts into consideration for this.
Mechanic. You don't necessarily need one per shift, but you will always need a mechanic of some sort. Someone to do body work, engine work, fix that ruddy door that keeps jamming. How many will you need? Depends on the size of the ship.
Doctor/medic. People will get injured, get sick, eat the wrong thing, get pregnant, want to get pregnant. Consider dental, general health maintenance, do you have kids aboard? Surgeries are a thing, and you'll need someone on staff to handle that. What common illnesses can you expect? They'll need to be prepped for that.
Pharmacy. Do you just order what you need at every port of call? Or do you need someone aboard who can make what the doctor/medic requires? There's value in both, but can you imagine being lightyears from the nearest hospital/pharmacy and you're out of painkillers or life-saving drugs?
Entertainers. You can say this is a military craft until you're blue in the face. The last thing you need is nothing to do on a journey that could be months or years at a time. Sure, they'll have things to do during their shifts. But how long before that isn't enough? You need something to keep their spirits up. Music, dance, perhaps even drinking and games. They need something, and you need to figure out what. (consider the shifts, consider the need to have this made available around the clock).
Mooks. No matter the story you're trying to tell, you need mooks. The people doing the legwork. Perhaps as your 'red-shirts' that need to do the dying, or your 'storm troopers' that need to do the killing.
Food. People need to eat. Are you growing your food on the ship? Are you buying at port of call? More importantly: are you buying MREs at port of call?
Farmers to grow, is one thing. Cooking staff to prepare meals, is another thing. Someone dedicated to issuing rations to all hands, is a thing all on its own. Run out, just once, and be even a day out from the a port, and see how this affects morale and the inclination to mutiny.
Niceties. Separate from, but intrinsically linked to, entertainers. Unless you're re-imagining Sparta in Space, your people will want some small nice things. Personal belongings are one thing. Laundry in constant need of washing, halls in need of cleaning, toilets in need of unclogging... all these things need to be considered. How are you dividing this? Is one person in charge of issuing these duties? An XO could be useful, but you'll need one per shift. Is everyone in charge of maintaining their own quarters? Someone needs to check that, because one filthy sailor over the course of months is a health hazard.
How you delve into all this depends on the total size of ship, shifts per cycle, and a host of other details. So specific numbers is nigh impossible to offer you. But I hope I've given at least some insight into what you need to consider.