A general rule of thumb states that 1-inch of fish per 2 Gallons of water is appropriate. But this should only be taken under consideration to give you a basic idea and feeling towards the limit. Too many fish will eventually result in diseases due to stress. Caused by various factors, such as territorial fights, fin nipping, degradation of water quality due to excessive waste production, etc. The more severe problem caused by too many fish is the resulting waste.
Filtration is the secret and key indicator.
You can t stock more fish, than the filtration system can handle. Track your water parameters on a regular basis, and keep your filter well maintained. Fish are usually bought as juveniles and grow up to their adult size in your tank. Make sure to do your homework in research, not only about their adult size, but also behavior, compatibility, eating habits, light and water requirements. Do not hesitate to take fish back to the pet store, many of them will give you credit for them.