The number of itemId
s in your list will be the same as the number of elements in your list:
int itemCount = list.size();
However, if you're looking to count the number of unique itemIds (per @pst) then you should use a set to keep track of them.
Set<String> itemIds = new HashSet<String>();
//...
itemId = p.getItemId();
itemIds.add(itemId);
//... later ...
int uniqueItemIdCount = itemIds.size();