If the name should be short, then the following approaches can be used:
- Common abbreviations. The common abbreviation for number is num.
- The abbreviation of words by removing all or some vowels. Pieces can be cut to pcs. In this case, this is particularly successful, since in English it is also a common abbreviation, even Google translator adequately translates "pcs".
Thus, depending on the standard adopted in your language, your variable can be designated by one of the following options:
num_pcs, numPcs, NumPcs, and so on.
With a strong desire to make it even shorter, you can shrink num to the letter 'n'. This is a less transparent option, and if it is important that the name is obvious, it is better not to use it. However, the designation of the number one by the first letter in programming is still common, and many programmers can guess without comment what the names n_pcs, nPcs and NPcs mean.
If you still need a variable for the index, then use something like cur_piece or cur_el (cur is a common abbreviation for current; el is a common abbreviation for element)