Give a more specific example. Are you wanting to know how determine how many free slots you have in a bag...or are you talking about knowing how many one particular item you have in a particular bag (versus overall)?
Also, what's the practical purpose of this inquiry?