How to count ONLY elements in the DOM/Inspector?

If some s have been removed from a dropdown, from the DOM because they are out of stock for example, how can I count ONLY the visible elements that I can see via the inspector?

Source code: There are 6 elements.
DOM: There are 4 elements.

I want to get the 4 count instead of 6.

Many thanks if you can help

Can you post any code (html, css, js) that you currently have?