You will need to count it and store it somewhere. (If it's a breakable item, you may be able to calculate it from the amount of damage/durability)