How is stellar mass of a galaxy obtained? I believe there is a difference between the mass calculated using the orbital speed and the stellar mass of the galaxy. So how is the stellar mass calculated?

Thank you :)
In short, you count stars. Of course you can't count or even see all the stars, so you have to count certain types of (bright) stars and then assume that the ratio of these to all the stars in their neighbourhood is similar to the ratio in a local part of the Galaxy where we can do a more complete census.

Once we have an idea of a number for the stars in any region, we can use an assumed mass distribution for the stars to calculate the total stellar mass.

There are details and nuances (e.g. the form of the stellar mass distribution depends on the age of the population), but that's the basic process in our own Galaxy.

In other galaxies, where you don't resolve individual stars, you work on the basis of mass to luminosity ratios for typical populations to convert a luminosity to a stellar mass.