I don't disagree with either reply but....
If the inputs are spared out or you don't want to count on in the middle for some reason, perhaps its a counter input or something, there is a longhand method which is simple and quick.
Assuming you are using in input map ladder, or code, that takes physical IO and maps it to memory bits, just good practice that, then all you need is a single int and a couple of instructions.
At the top of the map ladder/rung set you input count int to 0
On every rung/line that sets a memory bit to the input state inc the count by one.
you will not see any flutter because the int will only be set at the end of the scan, unless you made it volatile, which you shouldn't.
To be fair it is a bit longhand but then its also bulletproof and isn't reliant on card metadata or nicely grouped inputs.
It, the methodology, will of course work or any list of assignment statements or conditions, depending on your perspective - alarm count anyone?
BTW if you use a spreadsheet to build your code the time impact of adding a single extra instruction, for each input, is almost nothing!
Hope that helps,
Al