I don't care or want to know which individual bits are active, it's only the number of them that I want to know.

For eg if the input is 0000 0100 0101 0000 then the output would be 0011

An input of 1110 0011 1010 1100 would be 1001 etc.

Seems like a simple problem to solve but I've been racking my brain and only coming up with solutions that use loads of ICs.